示例#1
0
        /// <summary>
        /// Helper method to create a rush project
        /// </summary>
        public JavaScriptProject CreateRushProject(
            string projectName       = null,
            string scriptCommandName = null,
            string scriptCommand     = null,
            AbsolutePath?tempFolder  = null,
            IReadOnlyCollection <AbsolutePath> outputDirectories = null,
            IReadOnlyCollection <AbsolutePath> sourceFiles       = null,
            IReadOnlyCollection <JavaScriptProject> dependencies = null)
        {
            projectName ??= "@ms/rush-proj";

            var tempDirectory = tempFolder.HasValue ? tempFolder.Value : AbsolutePath.Create(PathTable, GetTempDir());
            var rushProject   = new JavaScriptProject(
                projectName,
                TestPath.Combine(PathTable, RelativePath.Create(StringTable, projectName)),
                scriptCommandName ?? "build",
                scriptCommand ?? "node ./main.js",
                tempDirectory,
                outputDirectories ?? CollectionUtilities.EmptyArray <AbsolutePath>(),
                sourceFiles ?? CollectionUtilities.EmptyArray <AbsolutePath>()
                );

            rushProject.SetDependencies(dependencies ?? CollectionUtilities.EmptyArray <JavaScriptProject>());

            return(rushProject);
        }
        public void SemistableHashesArePreservedForTheSameSchedule()
        {
            var projectA = CreateProjectWithPredictions("A.proj", outputs: new[] { TestPath.Combine(PathTable, "OutputDirA") }, inputs: new[] { TestPath.Combine(PathTable, "inputFileA") });
            var projectB = CreateProjectWithPredictions("B.proj", outputs: new[] { TestPath.Combine(PathTable, "OutputDirB") }, inputs: new[] { TestPath.Combine(PathTable, "inputFileB") });

            var processes = Start()
                            .Add(projectB)
                            .Add(projectA)
                            .ScheduleAll()
                            .AssertSuccess()
                            .RetrieveAllProcesses();

            var hashes = new HashSet <string>(processes.Select(pip => pip.FormattedSemiStableHash));

            // Schedule again with the same set of specs
            processes = Start()
                        .Add(projectB)
                        .Add(projectA)
                        .ScheduleAll()
                        .AssertSuccess()
                        .RetrieveAllProcesses();

            var hashes2 = new HashSet <string>(processes.Select(pip => pip.FormattedSemiStableHash));

            // Semistable hashes of both runs must be equivalent
            Assert.True(HashSet <string> .CreateSetComparer().Equals(hashes, hashes2));
        }
示例#3
0
        /// <summary>
        /// Helper method to create a project with predictions rooted at the test root
        /// </summary>
        /// <returns></returns>
        public ProjectWithPredictions CreateProjectWithPredictions(
            string projectName = null,
            IReadOnlyCollection <AbsolutePath> inputs       = null,
            IReadOnlyCollection <AbsolutePath> outputs      = null,
            IEnumerable <ProjectWithPredictions> references = null,
            GlobalProperties globalProperties = null,
            PredictedTargetsToExecute predictedTargetsToExecute = null,
            bool implementsTargetProtocol = true)
        {
            var projectNameRelative = RelativePath.Create(StringTable, projectName ?? "testProj.proj");

            // We need to simulate the project comes from MSBuild with /graph
            var properties = new Dictionary <string, string>(globalProperties ?? GlobalProperties.Empty);

            properties[PipConstructor.s_isGraphBuildProperty] = "true";

            var projectWithPredictions = new ProjectWithPredictions(
                TestPath.Combine(PathTable, projectNameRelative),
                implementsTargetProtocol,
                new GlobalProperties(properties),
                inputs ?? CollectionUtilities.EmptyArray <AbsolutePath>(),
                outputs ?? CollectionUtilities.EmptyArray <AbsolutePath>(),
                projectReferences: references?.ToArray() ?? null,
                predictedTargetsToExecute: predictedTargetsToExecute ?? PredictedTargetsToExecute.Create(new[] { "Build" }));

            return(projectWithPredictions);
        }
        public void DirectoryDependencyIsHonored()
        {
            var directoryOutput = TestPath.Combine(PathTable, "OutputDir");
            var projectB        = CreateProjectWithPredictions("B.proj");
            var projectA        = CreateProjectWithPredictions("A.proj", outputs: new[] { directoryOutput }, references: new[] { projectB });

            var result = Start()
                         .Add(projectB)
                         .Add(projectA)
                         .ScheduleAll()
                         .AssertSuccess();

            AssertDependencyAndDependent(projectB, projectA, result);
        }
示例#5
0
 private IReadOnlyCollection <AbsolutePath> CreatePath(params string[] paths)
 {
     return(paths.Select(path => TestPath.Combine(PathTable, RelativePath.Create(PathTable.StringTable, path))).ToList());
 }
示例#6
0
 private IReadOnlySet <AbsolutePath> Paths(params string[] paths)
 {
     return(paths.Select(p => TestPath.Combine(PathTable, p)).ToReadOnlySet());
 }