aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar mstaib <mstaib@google.com>2018-08-02 08:42:02 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-02 08:43:33 -0700
commitf29f78d19288f6d6e7aea6bc65e6bfa01b2531ad (patch)
tree80874e57d51e6f3b60c272fee9d4c7229145249c /src/test
parentca59cf38088e25a13fa244d8cd30d8a7197779a3 (diff)
Keep the analysis cache between builds when only trimmed test options change.
When --trim_test_configuration is on and the only options which have changed are from the (trimmed) TestOptions (not counting trim_test_configuration itself), preserve the analysis cache rather than dropping it all. This means that as long as no non-test options change, non-test rules will not need to be reanalyzed. This also applies to test rules which were analyzed with this configuration since the last time non-test options changed. For example: --test_arg=A //test (//test and its dependencies are analyzed) --test_arg=B //test (only //test is reanalyzed) --test_arg=A //test (no reanalysis needed) --test_arg=A --define=Test=A //test (full reanalysis) --test_arg=A //test (full reanalysis) RELNOTES: None. PiperOrigin-RevId: 207105915
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/test/TestTrimmingTransitionTest.java266
1 files changed, 266 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/test/TestTrimmingTransitionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/test/TestTrimmingTransitionTest.java
index 74d8cdba85..7ba5f6efb3 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/test/TestTrimmingTransitionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/test/TestTrimmingTransitionTest.java
@@ -235,6 +235,59 @@ public final class TestTrimmingTransitionTest extends AnalysisTestCase {
}
@Test
+ public void flagOffDifferentTestOptions_CacheCleared() throws Exception {
+ scratch.file(
+ "test/BUILD",
+ "load(':test.bzl', 'skylark_test')",
+ "load(':lib.bzl', 'skylark_lib')",
+ "test_suite(",
+ " name = 'suite',",
+ " tests = [':native_test', ':skylark_test'],",
+ ")",
+ "native_test(",
+ " name = 'native_test',",
+ " deps = [':native_dep', ':skylark_dep'],",
+ ")",
+ "skylark_test(",
+ " name = 'skylark_test',",
+ " deps = [':native_dep', ':skylark_dep'],",
+ ")",
+ "native_lib(",
+ " name = 'native_dep',",
+ " deps = [':native_shared_dep', 'skylark_shared_dep'],",
+ ")",
+ "skylark_lib(",
+ " name = 'skylark_dep',",
+ " deps = [':native_shared_dep', 'skylark_shared_dep'],",
+ ")",
+ "native_lib(",
+ " name = 'native_shared_dep',",
+ ")",
+ "skylark_lib(",
+ " name = 'skylark_shared_dep',",
+ ")");
+ useConfiguration("--notrim_test_configuration", "--noexpand_test_suites", "--test_arg=TypeA");
+ update("//test:suite");
+ useConfiguration("--notrim_test_configuration", "--noexpand_test_suites", "--test_arg=TypeB");
+ update("//test:suite");
+ useConfiguration("--notrim_test_configuration", "--noexpand_test_suites", "--test_arg=TypeA");
+ update("//test:suite");
+ // asserting that we got no overlap between the first and third runs, we had to reanalyze all
+ // seven targets
+ assertNumberOfConfigurationsOfTargets(
+ getSkyframeEvaluatedTargetKeys(),
+ new ImmutableMap.Builder<String, Integer>()
+ .put("//test:suite", 1)
+ .put("//test:native_test", 1)
+ .put("//test:skylark_test", 1)
+ .put("//test:native_dep", 1)
+ .put("//test:skylark_dep", 1)
+ .put("//test:native_shared_dep", 1)
+ .put("//test:skylark_shared_dep", 1)
+ .build());
+ }
+
+ @Test
public void flagOnDifferentTestOptions_SharesCTsForNonTestRules() throws Exception {
scratch.file(
"test/BUILD",
@@ -316,6 +369,219 @@ public final class TestTrimmingTransitionTest extends AnalysisTestCase {
}
@Test
+ public void flagOnDifferentTestOptions_CacheKeptBetweenRuns() throws Exception {
+ scratch.file(
+ "test/BUILD",
+ "load(':test.bzl', 'skylark_test')",
+ "load(':lib.bzl', 'skylark_lib')",
+ "test_suite(",
+ " name = 'suite',",
+ " tests = [':native_test', ':skylark_test'],",
+ ")",
+ "native_test(",
+ " name = 'native_test',",
+ " deps = [':native_dep', ':skylark_dep'],",
+ ")",
+ "skylark_test(",
+ " name = 'skylark_test',",
+ " deps = [':native_dep', ':skylark_dep'],",
+ ")",
+ "native_lib(",
+ " name = 'native_dep',",
+ " deps = [':native_shared_dep', 'skylark_shared_dep'],",
+ ")",
+ "skylark_lib(",
+ " name = 'skylark_dep',",
+ " deps = [':native_shared_dep', 'skylark_shared_dep'],",
+ ")",
+ "native_lib(",
+ " name = 'native_shared_dep',",
+ ")",
+ "skylark_lib(",
+ " name = 'skylark_shared_dep',",
+ ")");
+ useConfiguration("--trim_test_configuration", "--noexpand_test_suites", "--test_arg=TypeA");
+ update("//test:suite");
+ useConfiguration("--trim_test_configuration", "--noexpand_test_suites", "--test_arg=TypeB");
+ update("//test:suite");
+ // asserting that the non-test rules were cached from the last run and did not need to be run
+ // again
+ assertNumberOfConfigurationsOfTargets(
+ getSkyframeEvaluatedTargetKeys(),
+ new ImmutableMap.Builder<String, Integer>()
+ .put("//test:native_dep", 0)
+ .put("//test:skylark_dep", 0)
+ .put("//test:native_shared_dep", 0)
+ .put("//test:skylark_shared_dep", 0)
+ .build());
+ useConfiguration("--trim_test_configuration", "--noexpand_test_suites", "--test_arg=TypeA");
+ update("//test:suite");
+ // asserting that the test rules were cached from the first run and did not need to be run again
+ assertNumberOfConfigurationsOfTargets(
+ getSkyframeEvaluatedTargetKeys(),
+ new ImmutableMap.Builder<String, Integer>()
+ .put("//test:suite", 0)
+ .put("//test:native_test", 0)
+ .put("//test:skylark_test", 0)
+ .build());
+ }
+
+ @Test
+ public void flagOnDifferentNonTestOptions_CacheCleared() throws Exception {
+ scratch.file(
+ "test/BUILD",
+ "load(':test.bzl', 'skylark_test')",
+ "load(':lib.bzl', 'skylark_lib')",
+ "test_suite(",
+ " name = 'suite',",
+ " tests = [':native_test', ':skylark_test'],",
+ ")",
+ "native_test(",
+ " name = 'native_test',",
+ " deps = [':native_dep', ':skylark_dep'],",
+ ")",
+ "skylark_test(",
+ " name = 'skylark_test',",
+ " deps = [':native_dep', ':skylark_dep'],",
+ ")",
+ "native_lib(",
+ " name = 'native_dep',",
+ " deps = [':native_shared_dep', 'skylark_shared_dep'],",
+ ")",
+ "skylark_lib(",
+ " name = 'skylark_dep',",
+ " deps = [':native_shared_dep', 'skylark_shared_dep'],",
+ ")",
+ "native_lib(",
+ " name = 'native_shared_dep',",
+ ")",
+ "skylark_lib(",
+ " name = 'skylark_shared_dep',",
+ ")");
+ useConfiguration("--trim_test_configuration", "--noexpand_test_suites", "--define=Test=TypeA");
+ update("//test:suite");
+ useConfiguration("--trim_test_configuration", "--noexpand_test_suites", "--define=Test=TypeB");
+ update("//test:suite");
+ useConfiguration("--trim_test_configuration", "--noexpand_test_suites", "--define=Test=TypeA");
+ update("//test:suite");
+ // asserting that we got no overlap between the first and third runs, we had to reanalyze all
+ // seven targets
+ assertNumberOfConfigurationsOfTargets(
+ getSkyframeEvaluatedTargetKeys(),
+ new ImmutableMap.Builder<String, Integer>()
+ .put("//test:suite", 1)
+ .put("//test:native_test", 1)
+ .put("//test:skylark_test", 1)
+ .put("//test:native_dep", 1)
+ .put("//test:skylark_dep", 1)
+ .put("//test:native_shared_dep", 1)
+ .put("//test:skylark_shared_dep", 1)
+ .build());
+ }
+
+ @Test
+ public void flagOffToOn_CacheCleared() throws Exception {
+ scratch.file(
+ "test/BUILD",
+ "load(':test.bzl', 'skylark_test')",
+ "load(':lib.bzl', 'skylark_lib')",
+ "test_suite(",
+ " name = 'suite',",
+ " tests = [':native_test', ':skylark_test'],",
+ ")",
+ "native_test(",
+ " name = 'native_test',",
+ " deps = [':native_dep', ':skylark_dep'],",
+ ")",
+ "skylark_test(",
+ " name = 'skylark_test',",
+ " deps = [':native_dep', ':skylark_dep'],",
+ ")",
+ "native_lib(",
+ " name = 'native_dep',",
+ " deps = [':native_shared_dep', 'skylark_shared_dep'],",
+ ")",
+ "skylark_lib(",
+ " name = 'skylark_dep',",
+ " deps = [':native_shared_dep', 'skylark_shared_dep'],",
+ ")",
+ "native_lib(",
+ " name = 'native_shared_dep',",
+ ")",
+ "skylark_lib(",
+ " name = 'skylark_shared_dep',",
+ ")");
+ useConfiguration("--notrim_test_configuration", "--noexpand_test_suites");
+ update("//test:suite");
+ useConfiguration("--trim_test_configuration", "--noexpand_test_suites");
+ update("//test:suite");
+ // asserting that we got no overlap between the first and second runs, we had to reanalyze all
+ // seven targets
+ assertNumberOfConfigurationsOfTargets(
+ getSkyframeEvaluatedTargetKeys(),
+ new ImmutableMap.Builder<String, Integer>()
+ .put("//test:suite", 1)
+ .put("//test:native_test", 1)
+ .put("//test:skylark_test", 1)
+ .put("//test:native_dep", 1)
+ .put("//test:skylark_dep", 1)
+ .put("//test:native_shared_dep", 1)
+ .put("//test:skylark_shared_dep", 1)
+ .build());
+ }
+
+ @Test
+ public void flagOnToOff_CacheCleared() throws Exception {
+ scratch.file(
+ "test/BUILD",
+ "load(':test.bzl', 'skylark_test')",
+ "load(':lib.bzl', 'skylark_lib')",
+ "test_suite(",
+ " name = 'suite',",
+ " tests = [':native_test', ':skylark_test'],",
+ ")",
+ "native_test(",
+ " name = 'native_test',",
+ " deps = [':native_dep', ':skylark_dep'],",
+ ")",
+ "skylark_test(",
+ " name = 'skylark_test',",
+ " deps = [':native_dep', ':skylark_dep'],",
+ ")",
+ "native_lib(",
+ " name = 'native_dep',",
+ " deps = [':native_shared_dep', 'skylark_shared_dep'],",
+ ")",
+ "skylark_lib(",
+ " name = 'skylark_dep',",
+ " deps = [':native_shared_dep', 'skylark_shared_dep'],",
+ ")",
+ "native_lib(",
+ " name = 'native_shared_dep',",
+ ")",
+ "skylark_lib(",
+ " name = 'skylark_shared_dep',",
+ ")");
+ useConfiguration("--trim_test_configuration", "--noexpand_test_suites");
+ update("//test:suite");
+ useConfiguration("--notrim_test_configuration", "--noexpand_test_suites");
+ update("//test:suite");
+ // asserting that we got no overlap between the first and second runs, we had to reanalyze all
+ // seven targets
+ assertNumberOfConfigurationsOfTargets(
+ getSkyframeEvaluatedTargetKeys(),
+ new ImmutableMap.Builder<String, Integer>()
+ .put("//test:suite", 1)
+ .put("//test:native_test", 1)
+ .put("//test:skylark_test", 1)
+ .put("//test:native_dep", 1)
+ .put("//test:skylark_dep", 1)
+ .put("//test:native_shared_dep", 1)
+ .put("//test:skylark_shared_dep", 1)
+ .build());
+ }
+
+ @Test
public void flagOnDynamicConfigsNotrimHostDeps_AreNotAnalyzedAnyExtraTimes() throws Exception {
scratch.file(
"test/BUILD",