Esempio n. 1
0
        public void TestPipOutputFingerprinting(FileExistence existence, FileExistence anotherExistence)
        {
            // Arrange
            var          pathTable  = m_context.PathTable;
            var          executable = FileArtifact.CreateSourceFile(AbsolutePath.Create(pathTable, X("/x/pkgs/tool.exe")));
            AbsolutePath outputPath = AbsolutePath.Create(pathTable, X("/x/obj/working/out.bin"));

            FileArtifactWithAttributes output = new FileArtifactWithAttributes(outputPath, rewriteCount: 1, fileExistence: existence);
            Process process = DefaultBuilder.WithOutputs(output).Build();

            Process processSecondVersion = DefaultBuilder.WithOutputs(output.CreateNextWrittenVersion()).Build();

            var outputWithDifferenceExistence  = new FileArtifactWithAttributes(outputPath, rewriteCount: 1, fileExistence: anotherExistence);
            var processWithDifferenceExistence = DefaultBuilder.WithOutputs(outputWithDifferenceExistence).Build();

            var fingerprinter = CreateFingerprinter(executable);

            // Act
            var fingerprint = fingerprinter.ComputeFingerprint(process);

            // Assert
            XAssert.AreEqual(fingerprint, fingerprinter.ComputeFingerprint(processSecondVersion),
                             "RewriteCount should not affect the fingerprint");
            XAssert.AreNotEqual(fingerprint, fingerprinter.ComputeFingerprint(processWithDifferenceExistence),
                                "Two process with the same output path but with different attributes should produce different fingerprints");
        }