/// <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() ?? CollectionUtilities.EmptyArray <ProjectWithPredictions>(), predictedTargetsToExecute: predictedTargetsToExecute ?? PredictedTargetsToExecute.Create(new[] { "Build" })); return(projectWithPredictions); }
public void ProjectWithPredictedTargetsAreHonored() { var targetPredictedProject = CreateProjectWithPredictions( predictedTargetsToExecute: PredictedTargetsToExecute.Create(new[] { "foo" })); var process = Start() .Add(targetPredictedProject) .ScheduleAll() .AssertSuccess() .RetrieveSuccessfulProcess(targetPredictedProject); var arguments = RetrieveProcessArguments(process); Assert.Contains("/t:foo", arguments); }
/// <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) { var projectNameRelative = RelativePath.Create(StringTable, projectName ?? "testProj.proj"); var projectWithPredictions = new ProjectWithPredictions( TestPath.Combine(PathTable, projectNameRelative), globalProperties ?? GlobalProperties.Empty, inputs ?? CollectionUtilities.EmptyArray <AbsolutePath>(), outputs ?? CollectionUtilities.EmptyArray <AbsolutePath>(), projectReferences: references?.ToArray() ?? CollectionUtilities.EmptyArray <ProjectWithPredictions>(), predictedTargetsToExecute: predictedTargetsToExecute ?? PredictedTargetsToExecute.CreatePredictedTargetsToExecute(new[] { "Build" })); return(projectWithPredictions); }
public void NonLeafProjectNotImplementingTargetProtocolIsSuccesfullBasedOnConfig() { var leafProject = CreateProjectWithPredictions(predictedTargetsToExecute: PredictedTargetsToExecute.Create(new[] { "Build" })); var nonLeafProject = CreateProjectWithPredictions(implementsTargetProtocol: false, references: new[] { leafProject }); Start(new MsBuildResolverSettings { AllowProjectsToNotSpecifyTargetProtocol = true }) .Add(leafProject) .Add(nonLeafProject) .ScheduleAll() .AssertSuccess(); // if not specifying the protocol is allowed, we should succeed but log a warning AssertWarningEventLogged(LogEventId.ProjectIsNotSpecifyingTheProjectReferenceProtocol); AssertWarningCount(); }
public void LeafProjectNotImplementingTargetProtocolIsSuccesfullyScheduled() { var noTargetProtocolProject = CreateProjectWithPredictions(predictedTargetsToExecute: PredictedTargetsToExecute.Create(new string[] { "Build" }), implementsTargetProtocol: false); var process = Start() .Add(noTargetProtocolProject) .ScheduleAll() .AssertSuccess(); // The project doesn't have any references, so there should be an informational log AssertVerboseEventLogged(LogEventId.LeafProjectIsNotSpecifyingTheProjectReferenceProtocol, 1); AssertWarningCount(); }