示例#1
0
        private void DoTestRenderer(PathTable pathTable, PipFragmentRenderer renderer, string expectedHash)
        {
            // StringId
            var strValue = "my string";

            XAssert.AreEqual(strValue, renderer.Render(PipFragment.FromString(strValue, pathTable.StringTable)));

            var pathStr   = A("t", "file1.txt");
            var path      = AbsolutePath.Create(pathTable, pathStr);
            var srcFile   = FileArtifact.CreateSourceFile(path);
            var outFile   = FileArtifact.CreateOutputFile(srcFile);
            var rwFile    = outFile.CreateNextWrittenVersion();
            var rw2File   = rwFile.CreateNextWrittenVersion();
            var opaqueDir = DirectoryArtifact.CreateDirectoryArtifactForTesting(path, 0);
            var sharedDir = new DirectoryArtifact(path, 1, isSharedOpaque: true);

            // AbsolutePath
            XAssert.AreEqual(pathStr, renderer.Render(PipFragment.FromAbsolutePathForTesting(path)));
            XAssert.AreEqual(pathStr, renderer.Render(PipFragment.FromAbsolutePathForTesting(srcFile)));
            XAssert.AreEqual(pathStr, renderer.Render(PipFragment.FromAbsolutePathForTesting(outFile)));
            XAssert.AreEqual(pathStr, renderer.Render(PipFragment.FromAbsolutePathForTesting(rwFile)));
            XAssert.AreEqual(pathStr, renderer.Render(PipFragment.FromAbsolutePathForTesting(rw2File)));

            // VsoHash
            XAssert.AreEqual(expectedHash, renderer.Render(PipFragment.VsoHashFromFileForTesting(srcFile)));
            XAssert.AreEqual(expectedHash, renderer.Render(PipFragment.VsoHashFromFileForTesting(outFile)));
            XAssert.AreEqual(expectedHash, renderer.Render(PipFragment.VsoHashFromFileForTesting(rwFile)));
            XAssert.AreEqual(expectedHash, renderer.Render(PipFragment.VsoHashFromFileForTesting(rw2File)));

            XAssert.AreEqual(DirectoryId.ToString(opaqueDir), renderer.Render(PipFragment.DirectoryIdForTesting(opaqueDir)));
            XAssert.AreEqual(DirectoryId.ToString(sharedDir), renderer.Render(PipFragment.DirectoryIdForTesting(sharedDir)));
        }
示例#2
0
 public void TestCallingSetDirectoryArtifactMultipleTimesWithSameDirectoryArtifactShouldBeAllowed()
 {
     using (TestEnv env = TestEnv.CreateTestEnvWithPausedScheduler())
     {
         SealedDirectoryTable table         = new SealedDirectoryTable(env.PathTable);
         AbsolutePath         directoryPath = env.Paths.CreateAbsolutePath(env.ObjectRoot, "seal");
         FileArtifact         a             = FileArtifact.CreateSourceFile(env.Paths.CreateAbsolutePath(directoryPath, "a"));
         var partialSeal       = CreatePartialSeal(env, directoryPath, a);
         var directoryArtifact = DirectoryArtifact.CreateDirectoryArtifactForTesting(directoryPath, 1);
         partialSeal.SetDirectoryArtifact(directoryArtifact);
         partialSeal.SetDirectoryArtifact(directoryArtifact); // setting the same directory artifact multiple times should be fine
     }
 }
示例#3
0
 public void TestAddInitializedSealDirectoryWhilePatching()
 {
     using (TestEnv env = TestEnv.CreateTestEnvWithPausedScheduler())
     {
         SealedDirectoryTable table         = new SealedDirectoryTable(env.PathTable);
         AbsolutePath         directoryPath = env.Paths.CreateAbsolutePath(env.ObjectRoot, "seal");
         FileArtifact         a             = FileArtifact.CreateSourceFile(env.Paths.CreateAbsolutePath(directoryPath, "a"));
         var partialSeal       = CreatePartialSeal(env, directoryPath, a);
         var directoryArtifact = DirectoryArtifact.CreateDirectoryArtifactForTesting(directoryPath, 1);
         partialSeal.SetDirectoryArtifact(directoryArtifact);
         table.StartPatching(); // if not in IsPatching state, 'ReserveAndAddSeal' would fail
         ReserveAndAddSeal(table, partialSeal);
         table.FinishPatching();
     }
 }
示例#4
0
            /// <summary>
            /// Creates a directory artifact which may be queried with <see cref="ListSealedDirectoryContents"/>,
            /// and whose members may be queried with <see cref="TryQuerySealedInputContent"/>.
            /// Each mentioned path must have been added explicitly with <see cref="AddAbsentPath"/> or <see cref="AddFile"/>
            /// </summary>
            public DirectoryArtifact SealDir(string root, params string[] contents)
            {
                var rootPath = Path(root);

                FileArtifact[] artifacts = new FileArtifact[contents.Length];
                for (int i = 0; i < contents.Length; i++)
                {
                    var path = Path(contents[i]);
                    if (!path.IsWithin(Context.PathTable, rootPath))
                    {
                        XAssert.Fail("Root {0} does not contain {1}", root, contents[i]);
                    }

                    artifacts[i] = FileArtifact.CreateSourceFile(path);
                }

                DirectoryArtifact newArtifact = DirectoryArtifact.CreateDirectoryArtifactForTesting(rootPath, m_nextDirectorySealId++);

                m_env.SetSealedDirectoryContents(newArtifact, artifacts);
                return(newArtifact);
            }