aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2018-01-19 21:07:08 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-19 21:09:10 -0800
commitdd17d9fd7329954210e86b82798ff012cb34ebd2 (patch)
tree1b3c50d73c657c04b75e2e940cf1b0dff77c8ef9 /src/test
parent3215117dc5372c103459a6cd21274fc756e5a9c9 (diff)
RELNOTES: NONE. PiperOrigin-RevId: 182626819
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java123
1 files changed, 67 insertions, 56 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java b/src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java
index 97dea9ce93..0cb30db568 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java
@@ -604,11 +604,6 @@ public abstract class MockCcSupport {
setupCrosstool(config, toolchainBuilder.buildPartial());
}
- public void setupCrosstoolWithRelease(MockToolsConfig config, String crosstool)
- throws IOException {
- createCrosstoolPackage(config, false, true, null, null, crosstool);
- }
-
/**
* Creates a crosstool package by merging {@code toolchain} with the default mock CROSSTOOL file.
*/
@@ -618,31 +613,6 @@ public abstract class MockCcSupport {
}
/**
- * Create a new crosstool configuration specified by {@code builder}.
- *
- * <p>If used from a {@code BuildViewTestCase}, make sure to call {@code
- * BuildViewTestCase.invalidatePackages} after calling this method to force re-loading of the
- * crosstool's BUILD files.
- */
- public void setupCrosstoolFromScratch(MockToolsConfig config, CrosstoolBuilder builder)
- throws IOException {
- if (config.isRealFileSystem()) {
- throw new RuntimeException(
- "Cannot use setupCrosstoolFromScratch when config.isRealFileSystem() is true; "
- + "use this function only for unit tests.");
- }
- // TODO(klimek): Get the version information from the crosstool builder and set up the
- // crosstool with that information.
- createCrosstoolPackage(
- config,
- /*addEmbeddedRuntimes=*/ false,
- /*addModuleMap=*/ true,
- null,
- null,
- builder.build());
- }
-
- /**
* Create a crosstool package. For integration tests, it actually links in a working crosstool,
* for all other tests, it only creates a dummy package, with a working CROSSTOOL file.
*
@@ -655,7 +625,8 @@ public abstract class MockCcSupport {
boolean addModuleMap,
String staticRuntimesLabel,
String dynamicRuntimesLabel,
- CToolchain toolchain) throws IOException {
+ CToolchain toolchain)
+ throws IOException {
createCrosstoolPackage(
config,
addEmbeddedRuntimes,
@@ -682,6 +653,36 @@ public abstract class MockCcSupport {
crosstool);
}
+ public void setupCrosstoolWithRelease(MockToolsConfig config, String crosstool)
+ throws IOException {
+ createCrosstoolPackage(config, false, true, null, null, crosstool);
+ }
+
+ /**
+ * Create a new crosstool configuration specified by {@code builder}.
+ *
+ * <p>If used from a {@code BuildViewTestCase}, make sure to call {@code
+ * BuildViewTestCase.invalidatePackages} after calling this method to force re-loading of the
+ * crosstool's BUILD files.
+ */
+ public void setupCrosstoolFromScratch(MockToolsConfig config, CrosstoolBuilder builder)
+ throws IOException {
+ if (config.isRealFileSystem()) {
+ throw new RuntimeException(
+ "Cannot use setupCrosstoolFromScratch when config.isRealFileSystem() is true; "
+ + "use this function only for unit tests.");
+ }
+ // TODO(klimek): Get the version information from the crosstool builder and set up the
+ // crosstool with that information.
+ createCrosstoolPackage(
+ config,
+ /*addEmbeddedRuntimes=*/ false,
+ /*addModuleMap=*/ true,
+ null,
+ null,
+ builder.build());
+ }
+
protected static void createToolsCppPackage(MockToolsConfig config) throws IOException {
config.create(
"tools/cpp/BUILD",
@@ -712,27 +713,6 @@ public abstract class MockCcSupport {
createCrosstoolPackage(config, addEmbeddedRuntimes, /*addModuleMap=*/ true, null, null);
}
- protected String getCrosstoolTopPathForConfig(MockToolsConfig config) {
- if (config.isRealFileSystem()) {
- return getRealFilesystemCrosstoolTopPath();
- } else {
- return getMockCrosstoolPath();
- }
- }
-
- public abstract String getMockCrosstoolPath();
-
- public static PackageIdentifier getMockCrosstoolsTop() {
- try {
- return PackageIdentifier.create(
- RepositoryName.create(TestConstants.TOOLS_REPOSITORY),
- PathFragment.create(TestConstants.MOCK_CC_CROSSTOOL_PATH));
- } catch (LabelSyntaxException e) {
- Verify.verify(false);
- throw new AssertionError();
- }
- }
-
private void createCrosstoolPackage(
MockToolsConfig config,
boolean addEmbeddedRuntimes,
@@ -740,8 +720,13 @@ public abstract class MockCcSupport {
String staticRuntimesLabel,
String dynamicRuntimesLabel)
throws IOException {
- createCrosstoolPackage(config, addEmbeddedRuntimes, addModuleMap, staticRuntimesLabel,
- dynamicRuntimesLabel, readCrosstoolFile());
+ createCrosstoolPackage(
+ config,
+ addEmbeddedRuntimes,
+ addModuleMap,
+ staticRuntimesLabel,
+ dynamicRuntimesLabel,
+ readCrosstoolFile());
}
private void createCrosstoolPackage(
@@ -753,8 +738,13 @@ public abstract class MockCcSupport {
CToolchain toolchain)
throws IOException {
String crosstoolFile = mergeCrosstoolConfig(readCrosstoolFile(), toolchain);
- createCrosstoolPackage(config, addEmbeddedRuntimes, addModuleMap, staticRuntimesLabel,
- dynamicRuntimesLabel, crosstoolFile);
+ createCrosstoolPackage(
+ config,
+ addEmbeddedRuntimes,
+ addModuleMap,
+ staticRuntimesLabel,
+ dynamicRuntimesLabel,
+ crosstoolFile);
}
protected void createCrosstoolPackage(
@@ -779,6 +769,27 @@ public abstract class MockCcSupport {
}
}
+ protected String getCrosstoolTopPathForConfig(MockToolsConfig config) {
+ if (config.isRealFileSystem()) {
+ return getRealFilesystemCrosstoolTopPath();
+ } else {
+ return getMockCrosstoolPath();
+ }
+ }
+
+ public abstract String getMockCrosstoolPath();
+
+ public static PackageIdentifier getMockCrosstoolsTop() {
+ try {
+ return PackageIdentifier.create(
+ RepositoryName.create(TestConstants.TOOLS_REPOSITORY),
+ PathFragment.create(TestConstants.MOCK_CC_CROSSTOOL_PATH));
+ } catch (LabelSyntaxException e) {
+ Verify.verify(false);
+ throw new AssertionError();
+ }
+ }
+
public abstract String getMockCrosstoolVersion();
public abstract Label getMockCrosstoolLabel();