aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
diff options
context:
space:
mode:
authorGravatar Greg Estren <gregce@google.com>2016-05-18 17:16:08 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-05-19 16:27:39 +0000
commitdab67e02488e2271b05da6c3750a9f8e95618ad5 (patch)
tree1d99a4529e470a986d86126226c13dbbb3092b6b /src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
parentb791501ed1df8ff431ab947e87b1a850a840b466 (diff)
For tests that check against output paths, provide the ability to strip out the C++-contributed fragment.
e.g. provide the ability to translate: bazel-out/gcc-X-glibc-Y-x86-fastbuild/ to: bazel-out/fastbuild/ This applies to artifacts built with dynamic configurations for targets with no C++ fragments in their configuration. -- MOS_MIGRATED_REVID=122643518
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
index 93d62018f7..151a7031fa 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
@@ -1056,6 +1056,18 @@ public abstract class BuildViewTestCase extends FoundationTestCase {
}
/**
+ * Strips the C++-contributed prefix out of an output path when tests are run with dynamic
+ * configurations. e.g. turns "bazel-out/gcc-X-glibc-Y-k8-fastbuild/ to "bazel-out/fastbuild/".
+ *
+ * <p>This should be used for targets use configurations with C++ fragments.
+ */
+ protected String stripCppPrefixForDynamicConfigs(String outputPath) {
+ return targetConfig.useDynamicConfigurations()
+ ? AnalysisTestUtil.OUTPUT_PATH_CPP_PREFIX_PATTERN.matcher(outputPath).replaceFirst("")
+ : outputPath;
+ }
+
+ /**
* Gets a derived Artifact for testing in the subdirectory of the {@link
* BuildConfiguration#getGenfilesDirectory()} corresponding to the package of {@code owner}.
* So to specify a file foo/foo.o owned by target //foo:foo, {@code packageRelativePath} should