private ModuleRepository GenerateWorkspaceRepo(WorkspaceEvaluationHelper helper, SimpleGraph file2file, int[] selectedFiles) { XAssert.IsTrue(file2file.IsDAG(), "Must be a DAG"); var specs = selectedFiles .Select(i => { var specsToImport = file2file.OutgoingEdges(i).Select(e => e.Dest).ToList(); var specContent = GenerateSpec(i, specsToImport); return(new ModuleRepository.NameContentPair(GetSpecName(i), specContent)); }) .Concat(new[] { new ModuleRepository.NameContentPair(HelperSpecName, GetHelperSpecContent()), new ModuleRepository.NameContentPair(Qualifier, GetSpecWithDefaultQualifierContent()), }) .ToArray(); return(helper.NewModuleRepoWithPrelude().AddContent(TestModule, specs)); }
public async Task TestSimple() { const string Spec0 = "import {Transformer} from 'Sdk.Transformers';\r\nexport const x = Transformer.copyFile(f`src-x.txt`, Context.getNewOutputDirectory('test').combine('dest-x.txt'));"; const string Spec1 = "import {Transformer} from 'Sdk.Transformers';\r\nexport const y = Transformer.copyFile(f`src-y.txt`, Context.getNewOutputDirectory('test').combine('dest-y.txt'));"; var helperFull = new WorkspaceEvaluationHelper(TestOutputDirectory, context: null, forTesting: true); var testModule = ModuleDescriptor.CreateForTesting("MyModule1"); // evaluate full var repo = helperFull.NewModuleRepoWithPrelude().AddContent(testModule, Spec0, Spec1); var pipGraph = await helperFull.EvaluateAsync(repo); var fullGraphPipCounts = new Dictionary <PipType, int> { [PipType.CopyFile] = 2, }; AssertPipGraphCounts(pipGraph, fullGraphPipCounts); // evaluate partial without patching --> result is a smaller graph { var helperPartial = new WorkspaceEvaluationHelper(TestOutputDirectory, context: helperFull.FrontEndContext, forTesting: true); var partialRepo = helperPartial.NewModuleRepoWithPrelude().AddContent(testModule, Spec0); var newPipGraph = await helperPartial.EvaluateAsync(partialRepo); AssertPipGraphCounts(newPipGraph, new Dictionary <PipType, int> { [PipType.CopyFile] = 1, }); } // evaluate partial with patching --> same as full graph { // NOTE: must start with previous PathTable, because some paths from the old build might not be seen in the partial workspace var helperPartial = new WorkspaceEvaluationHelper(TestOutputDirectory, context: helperFull.FrontEndContext, forTesting: true); var partialRepo = helperPartial.NewModuleRepoWithPrelude().AddContent(testModule, Spec0); var changedSpecs = new[] { repo.GetPathToModuleAndSpec(testModule, 0) }; var newPipGraph = await helperPartial.EvaluateWithGraphPatchingAsync(partialRepo, oldPipGraph : pipGraph, changedSpecs : changedSpecs, specsToIgnore : null); AssertPipGraphCounts(newPipGraph, fullGraphPipCounts); } }