private static bool IsDependencyAndDependent(ProjectWithPredictions <AbsolutePath> dependency, ProjectWithPredictions <AbsolutePath> dependent, MsBuildSchedulingResult result)
        {
            // Unfortunately the test pip graph we are using doesn't keep track of dependencies/dependents. So we check there is a directory output of the dependency
            // that is a directory input for a dependent
            var dependencyProcess = result.RetrieveSuccessfulProcess(dependency);
            var dependentProcess  = result.RetrieveSuccessfulProcess(dependent);

            return(dependencyProcess.DirectoryOutputs.Any(directoryOutput => dependentProcess.DirectoryDependencies.Any(directoryDependency => directoryDependency == directoryOutput)));
        }
예제 #2
0
        /// <nodoc/>
        public MsBuildProjectSchedulingFailure(ProjectWithPredictions <AbsolutePath> project, string failure, PathTable pathTable)
        {
            Contract.RequiresNotNull(project);
            Contract.RequiresNotNull(pathTable);
            Contract.RequiresNotNullOrEmpty(failure);

            m_project   = project;
            m_failure   = failure;
            m_pathTable = pathTable;
        }
        public void StaticPredictionsAreSerialized()
        {
            string outputFile = Path.Combine(TemporaryDirectory, Guid.NewGuid().ToString());
            string entryPoint = Path.Combine(TemporaryDirectory, Guid.NewGuid().ToString());

            // Here we create a project that we know standard predictors are able to predict: a compile item and an 'OutDir' property, that the CSharp and OutDir predictors should catch
            File.WriteAllText(entryPoint,
                              @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
    <PropertyGroup>
        <OutDir>bin</OutDir>
    </PropertyGroup>
    <ItemGroup>
        <Compile Include=""Program.cs"" />
    </ItemGroup >
</Project>
");

            MsBuildGraphBuilder.BuildGraphAndSerialize(
                new MSBuildGraphBuilderArguments(
                    TestOutputDirectory,
                    new[] { entryPoint },
                    outputFile,
                    globalProperties: GlobalProperties.Empty,
                    mSBuildSearchLocations: new[] { TestDeploymentDir },
                    entryPointTargets: new string[0],
                    requestedQualifiers: new GlobalProperties[] { GlobalProperties.Empty },
                    allowProjectsWithoutTargetProtocol: false));

            var result = SimpleDeserializer.Instance.DeserializeGraph(outputFile);

            Assert.True(result.Succeeded);

            // There is a single project in this graph, which should have non-empty predictions
            ProjectWithPredictions <string> project = result.Result.ProjectNodes.Single();

            Assert.True(project.PredictedInputFiles.Count > 0, "Expected a non-empty collection of predicted input files");
            Assert.True(project.PredictedOutputFolders.Count > 0, "Expected a non-empty collection of predicted output folders");
        }
 private static void AssertDependencyAndDependent(ProjectWithPredictions <AbsolutePath> dependency, ProjectWithPredictions <AbsolutePath> dependent, MsBuildSchedulingResult result)
 {
     XAssert.IsTrue(IsDependencyAndDependent(dependency, dependent, result));
 }