Exemplo n.º 1
0
 public void AssertCacheMissEventLogged(params string[] requiredMessages)
 {
     if (Configuration.Logging.CacheMissAnalysisOption == CacheMissAnalysisOption.LocalMode())
     {
         AssertLogContains(caseSensitive: false, requiredLogMessages: requiredMessages);
     }
 }
Exemplo n.º 2
0
 public void AssertCacheMissEventLogged(params string[] requiredMessages)
 {
     if (Configuration.Logging.CacheMissAnalysisOption.Mode == CacheMissAnalysisOption.LocalMode().Mode)
     {
         var messages = requiredMessages.Select((s) => ObservedInputConstants.ToExpandedString(s));
         AssertLogContains(caseSensitive: false, requiredLogMessages: messages.ToArray());
     }
 }
Exemplo n.º 3
0
        public void FingerprintIsStableForCreatedDirectories()
        {
            string            dir            = Path.Combine(SourceRoot, "dir");
            AbsolutePath      dirPath        = AbsolutePath.Create(Context.PathTable, dir);
            DirectoryArtifact dirToEnumerate = DirectoryArtifact.CreateWithZeroPartialSealId(dirPath);

            Configuration.Logging.CacheMissAnalysisOption = CacheMissAnalysisOption.LocalMode();

            AbsolutePath nestedDirPath     = dirPath.Combine(Context.PathTable, "nested");
            var          nestedDir         = DirectoryArtifact.CreateWithZeroPartialSealId(nestedDirPath);
            var          outputInNestedDor = CreateOutputFileArtifact(nestedDirPath.ToString(Context.PathTable));

            // Create a pip that creates the directory to be enumerated
            var dirCreatorBuilder = CreatePipBuilder(new List <Operation>
            {
                // Create a directory nested into the one that is going to be enumerated
                Operation.CreateDir(nestedDir, doNotInfer: true),
                // Create a file underneath
                Operation.WriteFile(outputInNestedDor, doNotInfer: true),
                Operation.WriteFile(CreateOutputFileArtifact()) // dummy output
            });

            // This makes sure we use the right file system, which is aware of alien files
            dirCreatorBuilder.Options |= global::BuildXL.Pips.Operations.Process.Options.AllowUndeclaredSourceReads;
            // Define the shared opaque
            dirCreatorBuilder.AddOutputDirectory(dirPath, global::BuildXL.Pips.Operations.SealDirectoryKind.SharedOpaque);

            var dirCreator = SchedulePipBuilder(dirCreatorBuilder);

            // Create a pip that enumerates the directory
            var dirEnumeratorBuilder = CreatePipBuilder(new List <Operation>
            {
                Operation.EnumerateDir(dirToEnumerate, doNotInfer: true),
                Operation.WriteFile(CreateOutputFileArtifact()) // dummy output
            });

            // This makes sure we use the right file system, which is aware of alien files
            dirEnumeratorBuilder.Options |= global::BuildXL.Pips.Operations.Process.Options.AllowUndeclaredSourceReads;
            // Define the shared opaque
            dirEnumeratorBuilder.AddOutputDirectory(dirPath, global::BuildXL.Pips.Operations.SealDirectoryKind.SharedOpaque);
            // Make the enumerator depend on the creator
            dirEnumeratorBuilder.AddInputFile(dirCreator.ProcessOutputs.GetRequiredOutputFiles().Single());

            var dirEnumerator = SchedulePipBuilder(dirEnumeratorBuilder);

            // Run once. The created directory should be ignored for the enumeration fingerprint computation.
            RunScheduler().AssertSuccess();

            // Simulate shared opaque scrubbing
            FileUtilities.DeleteDirectoryContents(nestedDirPath.ToString(Context.PathTable), deleteRootDirectory: true);

            // This should be a cache hit. By replaying the dirCreator pip, the enumerated directory is re-created. However,
            // it should still be ignored by the fingerprint computation and we should get a cache hit.
            RunScheduler().AssertCacheHit(dirEnumerator.Process.PipId);
        }
        public void CreatedDirectoriesUnderSharedOpaquesAreNotPartOfTheFingerprint()
        {
            string            dir            = Path.Combine(SourceRoot, "dir");
            AbsolutePath      dirPath        = AbsolutePath.Create(Context.PathTable, dir);
            DirectoryArtifact dirToEnumerate = DirectoryArtifact.CreateWithZeroPartialSealId(dirPath);

            Configuration.Logging.CacheMissAnalysisOption = CacheMissAnalysisOption.LocalMode();

            AbsolutePath nestedDirPath = dirPath.Combine(Context.PathTable, "nested");
            var          nestedDir     = DirectoryArtifact.CreateWithZeroPartialSealId(nestedDirPath);

            var operations = new List <Operation>
            {
                // Create a directory nested into the one that is going to be enumerated
                Operation.CreateDir(nestedDir, doNotInfer: true),
                Operation.EnumerateDir(dirToEnumerate, doNotInfer: true),
                Operation.WriteFile(CreateOutputFileArtifact()) // dummy output
            };

            var builder = CreatePipBuilder(operations);

            // This makes sure we use the right file system, which is aware of alien files
            builder.Options |= global::BuildXL.Pips.Operations.Process.Options.AllowUndeclaredSourceReads;
            // Define the shared opaque
            builder.AddOutputDirectory(dirPath, global::BuildXL.Pips.Operations.SealDirectoryKind.SharedOpaque);

            var pip = SchedulePipBuilder(builder);

            // Run once
            RunScheduler().AssertSuccess();

            // Simulate shared opaque scrubbing
            FileUtilities.DeleteDirectoryContents(nestedDirPath.ToString(Context.PathTable), deleteRootDirectory: true);

            // This should be a cache hit. Directories created by a pip are not part of the fingerprint
            RunScheduler().AssertCacheHit(pip.Process.PipId);
        }
Exemplo n.º 5
0
 private void EnableFingerprintStore()
 {
     Configuration.Logging.StoreFingerprints       = true;
     Configuration.Logging.FingerprintStoreMode    = FingerprintStoreMode.ExecutionFingerprintsOnly;
     Configuration.Logging.CacheMissAnalysisOption = CacheMissAnalysisOption.LocalMode();
 }