/// <summary>
        /// Runs GenerateRuntimeGraph task specifying AdditionalRuntimeIdentifiers then asserts that the
        /// generated runtime.json has the expected additions (and no more).
        /// </summary>
        /// <param name="additionalRIDs">additional RIDs</param>
        /// <param name="expectedAdditions">entries that are expected to be added to the RuntimeGraph</param>
        /// <param name="additionalRIDParent">parent to use when adding a new RID</param>
        /// <param name="runtimeFilePrefix">a unique prefix to use for the generated </param>
        private void AssertRuntimeGraphAdditions(string[] additionalRIDs, RuntimeDescription[] expectedAdditions, string additionalRIDParent = null, [CallerMemberName] string runtimeFilePrefix = null)
        {
            string runtimeFile = Path.Combine(defaultRootPath, runtimeFilePrefix + ".runtime.json");

            GenerateRuntimeGraph task = new GenerateRuntimeGraph()
            {
                BuildEngine   = _engine,
                RuntimeGroups = DefaultRuntimeGroupItems,
                RuntimeJson   = runtimeFile,
                AdditionalRuntimeIdentifiers      = additionalRIDs,
                AdditionalRuntimeIdentifierParent = additionalRIDParent,
                UpdateRuntimeFiles = true
            };

            _log.Reset();
            task.Execute();
            _log.AssertNoErrorsOrWarnings();

            RuntimeGraph expected = RuntimeGraph.Merge(
                JsonRuntimeFormat.ReadRuntimeGraph(defaultRuntimeFile),
                new RuntimeGraph(expectedAdditions));

            RuntimeGraph actual = JsonRuntimeFormat.ReadRuntimeGraph(runtimeFile);

            // Should this assert fail, it's helpful to diff defaultRuntimeFile and runtimeFile to see the additions.
            Assert.Equal(expected, actual);
        }
        public void CanCreateRuntimeGraph()
        {
            // will generate and compare to existing file.
            GenerateRuntimeGraph task = new GenerateRuntimeGraph()
            {
                BuildEngine        = _engine,
                RuntimeGroups      = DefaultRuntimeGroupItems,
                RuntimeJson        = defaultRuntimeFile,
                UpdateRuntimeFiles = false
            };

            task.Execute();

            _log.AssertNoErrorsOrWarnings();
        }
        public void CanIgnoreExistingInferRids()
        {
            // will generate and compare to existing file.
            GenerateRuntimeGraph task = new GenerateRuntimeGraph()
            {
                BuildEngine   = _engine,
                RuntimeGroups = DefaultRuntimeGroupItems,
                RuntimeJson   = defaultRuntimeFile,
                AdditionalRuntimeIdentifiers = new[] { "rhel.9-x64", "centos.9-arm64", "win-x64" },
                UpdateRuntimeFiles           = false
            };

            _log.Reset();
            task.Execute();
            _log.AssertNoErrorsOrWarnings();
        }
Beispiel #4
0
        public void CanCreateRuntimeGraph()
        {
            string runtimeFile = "runtime.json";

            Project runtimeGroupProps = new Project("runtimeGroups.props");

            ITaskItem[] runtimeGroups = runtimeGroupProps.GetItems("RuntimeGroupWithQualifiers")
                                        .Select(i => CreateItem(i)).ToArray();

            Assert.NotEmpty(runtimeGroups);

            // will generate and compare to existing file.
            GenerateRuntimeGraph task = new GenerateRuntimeGraph()
            {
                BuildEngine   = _engine,
                RuntimeGroups = runtimeGroups,
                RuntimeJson   = runtimeFile
            };

            task.Execute();

            _log.AssertNoErrorsOrWarnings();
        }