Ejemplo n.º 1
0
        public void TestGraphFileSystem()
        {
            var harness = new Harness(Context.PathTable);

            // Rewritten file
            harness.AddArtifact(A("b", "dir", "out", "bin", "a2.dll"), 0);
            harness.AddArtifact(A("b", "dir", "out", "bin", "a2.dll"), 1);

            harness.AddArtifact(A("b", "dir", "out", "bin", "a3.dll"), 3);
            harness.AddArtifact(A("b", "dir", "out", "gen1.cs"), 1);
            harness.AddArtifact(A("b", "dir", "out", "gen2.cs"), 2);
            harness.AddArtifact(A("b", "dir", "a.cs"), 0);
            harness.AddArtifact(A("b", "dir", "b.cs"), 0);
            harness.AddArtifact(A("b", "dir", "output.dll"), 1);
            harness.AddArtifact(A("b", "src", "foo.txt"), 0);
            harness.AddArtifact(A("b", "src", "jab.txt"), 0);

            harness.AddRealPath(A("b", "src", "real.ds"), PathExistence.ExistsAsFile);

            harness.VerifyGraphExistence(A("b", "dir"), FileSystemViewMode.FullGraph, PathExistence.ExistsAsDirectory);
            harness.VerifyGraphExistence(A("b", "dir", "out"), FileSystemViewMode.FullGraph, PathExistence.ExistsAsDirectory);
            harness.VerifyGraphExistence(A("b", "dir", "out", "bin", "a2.dll"), FileSystemViewMode.FullGraph, PathExistence.ExistsAsFile);
            harness.VerifyGraphExistence(A("b", "dir", "out", "bin", "a3.dll"), FileSystemViewMode.FullGraph, PathExistence.ExistsAsFile);

            harness.VerifyGraphExistence(A("b", "dir"), FileSystemViewMode.Output, PathExistence.ExistsAsDirectory);
            harness.VerifyGraphExistence(A("b", "dir", "out"), FileSystemViewMode.Output, PathExistence.ExistsAsDirectory);
            harness.VerifyGraphExistence(A("b", "dir", "out", "bin", "a2.dll"), FileSystemViewMode.Output, PathExistence.ExistsAsFile);
            harness.VerifyGraphExistence(A("b", "dir", "out", "bin", "a3.dll"), FileSystemViewMode.Output, PathExistence.ExistsAsFile);

            // Paths which are non-existent in output graph but existent in full graph
            // Also verify they are non-existent in real fs
            harness.VerifyExistence(A("b", "src", "foo.txt"), FileSystemViewMode.Real, PathExistence.Nonexistent, shouldBeProbed: true);
            harness.VerifyGraphExistence(A("b", "src", "foo.txt"), FileSystemViewMode.FullGraph, PathExistence.ExistsAsFile);
            harness.VerifyGraphExistence(A("b", "src", "foo.txt"), FileSystemViewMode.Output, PathExistence.Nonexistent);

            harness.VerifyExistence(A("b", "src"), FileSystemViewMode.Real, PathExistence.ExistsAsDirectory, shouldBeProbed: true);
            harness.VerifyGraphExistence(A("b", "src"), FileSystemViewMode.FullGraph, PathExistence.ExistsAsDirectory);
            harness.VerifyGraphExistence(A("b", "src"), FileSystemViewMode.Output, PathExistence.Nonexistent);

            // Enumerate same directories in output graph and full graph
            harness.ExpectEnumerationMembers(A("b", ""), FileSystemViewMode.Output, Dir(A("b", "dir")));
            harness.ExpectEnumerationMembers(A("b", ""), FileSystemViewMode.FullGraph, Dir(A("b", "dir")), Dir(A("b", "src")));

            harness.ExpectEnumerationMembers(A("b", "dir"), FileSystemViewMode.Output, Dir(A("b", "dir", "out")), File(A("b", "dir", "output.dll")));
            harness.ExpectEnumerationMembers(A("b", "dir"), FileSystemViewMode.FullGraph, Dir(A("b", "dir", "out")), File(A("b", "dir", "output.dll")), File(A("b", "dir", "a.cs")), File(A("b", "dir", "b.cs")));

            // Query the same path in all three file systems which only exists on real file system
            harness.VerifyExistence(A("b", "src", "real.ds"), FileSystemViewMode.Real, PathExistence.ExistsAsFile, shouldBeProbed: true);
            harness.ResetProbes();

            harness.VerifyGraphExistence(A("b", "src", "real.ds"), FileSystemViewMode.FullGraph, PathExistence.Nonexistent);
            harness.ResetProbes();

            harness.VerifyGraphExistence(A("b", "src", "real.ds"), FileSystemViewMode.Output, PathExistence.Nonexistent);
            harness.ResetProbes();
        }
Ejemplo n.º 2
0
        public void TestExistenceInferenceOfRealFileSystem()
        {
            var harness = new Harness(Context.PathTable);

            harness.AddRealPath(A("c", "1", "a", "foo.txt"), PathExistence.ExistsAsFile);
            harness.AddRealPath(A("c", "2", "a", "foo.txt"), PathExistence.ExistsAsFile);
            harness.AddRealPath(A("c", "3", "a", "foo.txt"), PathExistence.ExistsAsFile);
            harness.AddRealPath(A("c", "4"), PathExistence.ExistsAsFile);

            harness.VerifyExistence(A("c", "1", "a", "foo.txt"), FileSystemViewMode.Real, PathExistence.ExistsAsFile, shouldBeProbed: true);

            // Parent paths of existent path are inferred as directories so no probe is necessary
            harness.VerifyExistence(A("c", "1", "a"), FileSystemViewMode.Real, PathExistence.ExistsAsDirectory, shouldBeProbed: false);
            harness.VerifyExistence(A("c", "1", ""), FileSystemViewMode.Real, PathExistence.ExistsAsDirectory, shouldBeProbed: false);
            harness.VerifyExistence(A("c", ""), FileSystemViewMode.Real, PathExistence.ExistsAsDirectory, shouldBeProbed: false);

            // Path in same directory is probed
            harness.VerifyExistence(A("c", "3"), FileSystemViewMode.Real, PathExistence.ExistsAsDirectory, shouldBeProbed: true);

            // Enumerate the c:\ directory and expect members
            harness.ExpectEnumerationMembers(A("c", ""), FileSystemViewMode.Real, Dir(A("c", "1")), Dir(A("c", "2")), Dir(A("c", "3")), File(A("c", "4")));

            // Existent paths in enumerated directories do not need to be probed
            harness.VerifyExistence(A("c", "2"), FileSystemViewMode.Real, PathExistence.ExistsAsDirectory, shouldBeProbed: false);
            harness.VerifyExistence(A("c", "4"), FileSystemViewMode.Real, PathExistence.ExistsAsFile, shouldBeProbed: false);

            // Absent paths in enumerated directories do not need to be probed
            harness.VerifyExistence(A("c", "5"), FileSystemViewMode.Real, PathExistence.Nonexistent, shouldBeProbed: false);
            harness.VerifyExistence(A("c", "nonexistent"), FileSystemViewMode.Real, PathExistence.Nonexistent, shouldBeProbed: false);

            // Child paths of absent paths in enumerated directories do not need to be probed
            harness.VerifyExistence(A("c", "missing", "subpath", "deep", "chain"), FileSystemViewMode.Real, PathExistence.Nonexistent, shouldBeProbed: false);
            harness.VerifyExistence(A("c", "missing", "subpath", "deep"), FileSystemViewMode.Real, PathExistence.Nonexistent, shouldBeProbed: false);
            harness.VerifyExistence(A("c", "missing", "subpath"), FileSystemViewMode.Real, PathExistence.Nonexistent, shouldBeProbed: false);
            harness.VerifyExistence(A("c", "missing"), FileSystemViewMode.Real, PathExistence.Nonexistent, shouldBeProbed: false);
        }