Search in sources :

Example 1 with TimestampGranularityMonitor

use of com.google.devtools.build.lib.util.io.TimestampGranularityMonitor in project bazel by bazelbuild.

the class SkyframeLabelVisitorTest method testSubpackageBoundarySubincludes.

// Regression test for: "package loading ignores subincludes for purposes of checking for
// subpackages cutting of labels"
//
// Indirectly tests that there are dependencies between a package and other packages that could
// potentially cutoff its subincludes.
@Test
public void testSubpackageBoundarySubincludes() throws Exception {
    // This test uses the python preprocessor.
    preprocessorFactorySupplier.inject(new SubincludePreprocessor(scratch.getFileSystem(), getSkyframeExecutor().getPackageManager()));
    PackageCacheOptions packageCacheOptions = Options.getDefaults(PackageCacheOptions.class);
    packageCacheOptions.defaultVisibility = ConstantRuleVisibility.PRIVATE;
    packageCacheOptions.showLoadingProgress = true;
    packageCacheOptions.globbingThreads = 7;
    getSkyframeExecutor().preparePackageLoading(new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)), packageCacheOptions, loadingMock.getDefaultsPackageContent(), UUID.randomUUID(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of(), new TimestampGranularityMonitor(BlazeClock.instance()));
    this.visitor = getSkyframeExecutor().pkgLoader();
    scratch.file("a/BUILD", "subinclude('//b:c/d/foo')");
    scratch.file("b/BUILD", "exports_files(['c/d/foo'])");
    scratch.file("b/c/d/foo", "sh_library(name = 'a')");
    assertLabelsVisited(ImmutableSet.of("//a:a"), ImmutableSet.of("//a:a"), !EXPECT_ERROR, !KEEP_GOING);
    Path subpackageBuildFile = scratch.file("b/c/BUILD", "exports_files(['foo'])");
    syncPackages(ModifiedFileSet.builder().modify(new PathFragment("b/c/BUILD")).build());
    // expect errors
    reporter.removeHandler(failFastHandler);
    assertLabelsVisitedWithErrors(ImmutableSet.of("//a:a"), ImmutableSet.of("//a:a"));
    assertContainsEvent("Label '//b:c/d/foo' crosses boundary of subpackage 'b/c'");
    subpackageBuildFile.delete();
    syncPackages(ModifiedFileSet.builder().modify(new PathFragment("b/c/BUILD")).build());
    assertLabelsVisited(ImmutableSet.of("//a:a"), ImmutableSet.of("//a:a"), !EXPECT_ERROR, !KEEP_GOING);
}
Also used : PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) Path(com.google.devtools.build.lib.vfs.Path) SubincludePreprocessor(com.google.devtools.build.lib.packages.util.SubincludePreprocessor) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) PackageCacheOptions(com.google.devtools.build.lib.pkgcache.PackageCacheOptions) TimestampGranularityMonitor(com.google.devtools.build.lib.util.io.TimestampGranularityMonitor) Test(org.junit.Test)

Example 2 with TimestampGranularityMonitor

use of com.google.devtools.build.lib.util.io.TimestampGranularityMonitor in project bazel by bazelbuild.

the class SkyframeLabelVisitorTest method testWithNoSubincludes.

@Test
public void testWithNoSubincludes() throws Exception {
    // This test uses the preprocessor.
    preprocessorFactorySupplier.inject(new SubincludePreprocessor(scratch.getFileSystem(), getSkyframeExecutor().getPackageManager()));
    PackageCacheOptions packageCacheOptions = Options.getDefaults(PackageCacheOptions.class);
    packageCacheOptions.defaultVisibility = ConstantRuleVisibility.PRIVATE;
    packageCacheOptions.showLoadingProgress = true;
    packageCacheOptions.globbingThreads = 7;
    getSkyframeExecutor().preparePackageLoading(new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)), packageCacheOptions, loadingMock.getDefaultsPackageContent(), UUID.randomUUID(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of(), new TimestampGranularityMonitor(BlazeClock.instance()));
    this.visitor = getSkyframeExecutor().pkgLoader();
    scratch.file("pkg/BUILD", "sh_library(name = 'x', deps = ['z'])", "sh_library(name = 'z')");
    assertLabelsVisited(ImmutableSet.of("//pkg:x", "//pkg:z"), ImmutableSet.of("//pkg:x"), !EXPECT_ERROR, !KEEP_GOING);
    assertLabelsVisited(ImmutableSet.of("//pkg:x", "//pkg:z"), ImmutableSet.of("//pkg:x"), !EXPECT_ERROR, !KEEP_GOING);
    scratch.file("hassub/BUILD", "subinclude('//sub:sub')");
    scratch.file("sub/BUILD", "exports_files(['sub'])");
    scratch.file("sub/sub", "sh_library(name='zzz')");
    assertLabelsVisited(ImmutableSet.of("//hassub:zzz"), ImmutableSet.of("//hassub:zzz"), !EXPECT_ERROR, !KEEP_GOING);
}
Also used : PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) SubincludePreprocessor(com.google.devtools.build.lib.packages.util.SubincludePreprocessor) PackageCacheOptions(com.google.devtools.build.lib.pkgcache.PackageCacheOptions) TimestampGranularityMonitor(com.google.devtools.build.lib.util.io.TimestampGranularityMonitor) Test(org.junit.Test)

Example 3 with TimestampGranularityMonitor

use of com.google.devtools.build.lib.util.io.TimestampGranularityMonitor in project bazel by bazelbuild.

the class AnalysisTestCase method update.

/**
   * Update the BuildView: syncs the package cache; loads and analyzes the given labels.
   */
protected AnalysisResult update(EventBus eventBus, FlagBuilder config, ImmutableList<String> aspects, String... labels) throws Exception {
    Set<Flag> flags = config.flags;
    LoadingOptions loadingOptions = Options.getDefaults(LoadingOptions.class);
    BuildView.Options viewOptions = optionsParser.getOptions(BuildView.Options.class);
    viewOptions.keepGoing = flags.contains(Flag.KEEP_GOING);
    viewOptions.loadingPhaseThreads = LOADING_PHASE_THREADS;
    BuildOptions buildOptions = ruleClassProvider.createBuildOptions(optionsParser);
    PackageCacheOptions packageCacheOptions = optionsParser.getOptions(PackageCacheOptions.class);
    PathPackageLocator pathPackageLocator = PathPackageLocator.create(outputBase, packageCacheOptions.packagePath, reporter, rootDirectory, rootDirectory);
    packageCacheOptions.showLoadingProgress = true;
    packageCacheOptions.globbingThreads = 7;
    skyframeExecutor.preparePackageLoading(pathPackageLocator, packageCacheOptions, ruleClassProvider.getDefaultsPackageContent(analysisMock.getInvocationPolicyEnforcer().getInvocationPolicy()), UUID.randomUUID(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of(), new TimestampGranularityMonitor(BlazeClock.instance()));
    skyframeExecutor.invalidateFilesUnderPathForTesting(reporter, ModifiedFileSet.EVERYTHING_MODIFIED, rootDirectory);
    LoadingResult loadingResult = loadingPhaseRunner.execute(reporter, ImmutableList.copyOf(labels), PathFragment.EMPTY_FRAGMENT, loadingOptions, viewOptions.keepGoing, /*determineTests=*/
    false, /*callback=*/
    null);
    BuildRequestOptions requestOptions = optionsParser.getOptions(BuildRequestOptions.class);
    ImmutableSortedSet<String> multiCpu = ImmutableSortedSet.copyOf(requestOptions.multiCpus);
    masterConfig = skyframeExecutor.createConfigurations(reporter, configurationFactory, buildOptions, multiCpu, false);
    analysisResult = buildView.update(loadingResult, masterConfig, aspects, viewOptions, AnalysisTestUtil.TOP_LEVEL_ARTIFACT_CONTEXT, reporter, eventBus);
    return analysisResult;
}
Also used : BuildView(com.google.devtools.build.lib.analysis.BuildView) PackageCacheOptions(com.google.devtools.build.lib.pkgcache.PackageCacheOptions) LoadingOptions(com.google.devtools.build.lib.pkgcache.LoadingOptions) PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) LoadingResult(com.google.devtools.build.lib.pkgcache.LoadingResult) BuildRequestOptions(com.google.devtools.build.lib.buildtool.BuildRequest.BuildRequestOptions) BuildOptions(com.google.devtools.build.lib.analysis.config.BuildOptions) TimestampGranularityMonitor(com.google.devtools.build.lib.util.io.TimestampGranularityMonitor)

Example 4 with TimestampGranularityMonitor

use of com.google.devtools.build.lib.util.io.TimestampGranularityMonitor in project bazel by bazelbuild.

the class BuildViewTestCase method initializeSkyframeExecutor.

@Before
public final void initializeSkyframeExecutor() throws Exception {
    analysisMock = getAnalysisMock();
    directories = new BlazeDirectories(outputBase, outputBase, rootDirectory, analysisMock.getProductName());
    binTools = BinTools.forUnitTesting(directories, analysisMock.getEmbeddedTools());
    mockToolsConfig = new MockToolsConfig(rootDirectory, false);
    analysisMock.setupMockClient(mockToolsConfig);
    analysisMock.setupMockWorkspaceFiles(directories.getEmbeddedBinariesRoot());
    packageCacheOptions = parsePackageCacheOptions();
    workspaceStatusActionFactory = new AnalysisTestUtil.DummyWorkspaceStatusActionFactory(directories);
    mutableActionGraph = new MapBasedActionGraph();
    ruleClassProvider = getRuleClassProvider();
    configurationFactory = analysisMock.createConfigurationFactory(ruleClassProvider.getConfigurationFragments());
    pkgFactory = analysisMock.getPackageFactoryForTesting().create(ruleClassProvider, getPlatformSetRegexps(), getEnvironmentExtensions(), scratch.getFileSystem());
    tsgm = new TimestampGranularityMonitor(BlazeClock.instance());
    skyframeExecutor = SequencedSkyframeExecutor.create(pkgFactory, directories, binTools, workspaceStatusActionFactory, ruleClassProvider.getBuildInfoFactories(), ImmutableList.<DiffAwareness.Factory>of(), Predicates.<PathFragment>alwaysFalse(), getPreprocessorFactorySupplier(), analysisMock.getSkyFunctions(), getPrecomputedValues(), ImmutableList.<SkyValueDirtinessChecker>of(), analysisMock.getProductName(), CrossRepositoryLabelViolationStrategy.ERROR, ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL, BuildFileName.BUILD));
    packageCacheOptions.defaultVisibility = ConstantRuleVisibility.PUBLIC;
    packageCacheOptions.showLoadingProgress = true;
    packageCacheOptions.globbingThreads = 7;
    skyframeExecutor.preparePackageLoading(new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)), packageCacheOptions, "", UUID.randomUUID(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of(), tsgm);
    useConfiguration();
    setUpSkyframe();
    // Also initializes ResourceManager.
    ResourceManager.instance().setAvailableResources(getStartingResources());
}
Also used : MockToolsConfig(com.google.devtools.build.lib.packages.util.MockToolsConfig) PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) BlazeDirectories(com.google.devtools.build.lib.analysis.BlazeDirectories) MapBasedActionGraph(com.google.devtools.build.lib.actions.MapBasedActionGraph) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) PackageFactory(com.google.devtools.build.lib.packages.PackageFactory) MiddlemanFactory(com.google.devtools.build.lib.actions.MiddlemanFactory) ConfigurationFactory(com.google.devtools.build.lib.analysis.config.ConfigurationFactory) TimestampGranularityMonitor(com.google.devtools.build.lib.util.io.TimestampGranularityMonitor) SkyValueDirtinessChecker(com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker) Before(org.junit.Before)

Example 5 with TimestampGranularityMonitor

use of com.google.devtools.build.lib.util.io.TimestampGranularityMonitor in project bazel by bazelbuild.

the class PackageLoadingTestCase method setUpSkyframe.

private void setUpSkyframe(PackageCacheOptions packageCacheOptions) {
    PathPackageLocator pkgLocator = PathPackageLocator.create(outputBase, packageCacheOptions.packagePath, reporter, rootDirectory, rootDirectory);
    packageCacheOptions.showLoadingProgress = true;
    packageCacheOptions.globbingThreads = GLOBBING_THREADS;
    skyframeExecutor.preparePackageLoading(pkgLocator, packageCacheOptions, loadingMock.getDefaultsPackageContent(), UUID.randomUUID(), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of(), new TimestampGranularityMonitor(BlazeClock.instance()));
    skyframeExecutor.setDeletedPackages(ImmutableSet.copyOf(packageCacheOptions.getDeletedPackages()));
}
Also used : PathPackageLocator(com.google.devtools.build.lib.pkgcache.PathPackageLocator) TimestampGranularityMonitor(com.google.devtools.build.lib.util.io.TimestampGranularityMonitor)

Aggregations

TimestampGranularityMonitor (com.google.devtools.build.lib.util.io.TimestampGranularityMonitor)17 PathPackageLocator (com.google.devtools.build.lib.pkgcache.PathPackageLocator)12 PackageCacheOptions (com.google.devtools.build.lib.pkgcache.PackageCacheOptions)9 BlazeDirectories (com.google.devtools.build.lib.analysis.BlazeDirectories)4 Path (com.google.devtools.build.lib.vfs.Path)4 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)4 Before (org.junit.Before)4 ConfigurationFactory (com.google.devtools.build.lib.analysis.config.ConfigurationFactory)3 PackageFactory (com.google.devtools.build.lib.packages.PackageFactory)3 SkyValueDirtinessChecker (com.google.devtools.build.lib.skyframe.SkyValueDirtinessChecker)3 RecordingDifferencer (com.google.devtools.build.skyframe.RecordingDifferencer)3 BuildView (com.google.devtools.build.lib.analysis.BuildView)2 MockToolsConfig (com.google.devtools.build.lib.packages.util.MockToolsConfig)2 SubincludePreprocessor (com.google.devtools.build.lib.packages.util.SubincludePreprocessor)2 InMemoryMemoizingEvaluator (com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator)2 SequentialBuildDriver (com.google.devtools.build.skyframe.SequentialBuildDriver)2 SkyFunction (com.google.devtools.build.skyframe.SkyFunction)2 SkyFunctionName (com.google.devtools.build.skyframe.SkyFunctionName)2 SkyKey (com.google.devtools.build.skyframe.SkyKey)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2