diff options
author | 2018-05-18 05:19:20 -0700 | |
---|---|---|
committer | 2018-05-18 05:21:19 -0700 | |
commit | fd44bae268f74e3b308d03b8e3710ee9442cd851 (patch) | |
tree | 99922c50e71c20b85305cb451f510747f5798b9d /src/test/java/com | |
parent | e854c86bde5af363e03b87dcf46e629dce694c17 (diff) |
Refactor artifact_name_pattern in CROSSTOOL
Instead of using a string pattern, we replace it with a prefix and an
extension.
RELNOTES: NONE
PiperOrigin-RevId: 197132215
Diffstat (limited to 'src/test/java/com')
3 files changed, 12 insertions, 30 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 64ed3c068d..4cc1620711 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 @@ -477,21 +477,16 @@ public abstract class MockCcSupport { "" + "artifact_name_pattern {" + " category_name: 'static_library'" - + " pattern: 'lib%{base_name}.tweaked.a'" + + " prefix: 'lib'" + + " extension: '.tweaked.a'" + "}"; public static final String STATIC_LINK_AS_DOT_A_CONFIGURATION = "" + "artifact_name_pattern {" + " category_name: 'static_library'" - + " pattern: 'lib%{base_name}.a'" - + "}"; - - public static final String STATIC_LINK_BAD_TEMPLATE_CONFIGURATION = - "" - + "artifact_name_pattern {" - + " category_name: 'static_library'" - + " pattern: 'foo%{bad_variable}bar'" + + " prefix: 'lib'" + + " extension: '.a'" + "}"; public static final String EMPTY_COMPILE_ACTION_CONFIG = diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java index 14779030d9..dd864bc08c 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java @@ -17,7 +17,6 @@ package com.google.devtools.build.lib.rules.cpp; import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.fail; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; @@ -359,10 +358,12 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase { public void testObjectFileNamesCanBeSpecifiedInToolchain() throws Exception { AnalysisMock.get() .ccSupport() - .setupCrosstool(mockToolsConfig, + .setupCrosstool( + mockToolsConfig, "artifact_name_pattern {" + " category_name: 'object_file'" - + " pattern: '%{output_name}.test.o'" + + " prefix: ''" + + " extension: '.test.o'" + "}"); useConfiguration(); @@ -383,22 +384,6 @@ public class CcLibraryConfiguredTargetTest extends BuildViewTestCase { } @Test - public void testArtifactSelectionErrorOnBadTemplateVariable() throws Exception { - AnalysisMock.get() - .ccSupport() - .setupCrosstool(mockToolsConfig, MockCcSupport.STATIC_LINK_BAD_TEMPLATE_CONFIGURATION); - useConfiguration("--features=" + Link.LinkTargetType.STATIC_LIBRARY.getActionName()); - try { - getConfiguredTarget("//hello:hello"); - fail("Should fail"); - } catch (AssertionError e) { - assertThat(e) - .hasMessageThat() - .contains("Invalid toolchain configuration: Cannot find variable named 'bad_variable'"); - } - } - - @Test public void testArtifactsToAlwaysBuild() throws Exception { useConfiguration("--cpu=k8"); // ArtifactsToAlwaysBuild should apply both for static libraries. diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java index 6c04b605eb..a780425d10 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeaturesTest.java @@ -1724,7 +1724,8 @@ public class CcToolchainFeaturesTest extends FoundationTestCase { buildFeatures( "artifact_name_pattern {", "category_name: 'NONEXISTENT_CATEGORY'", - "pattern: 'some_pattern'}"); + "prefix: 'foo'", + "extension: 'bar'}"); fail("Should throw InvalidConfigurationException."); } catch (InvalidConfigurationException e) { assertThat(e) @@ -1740,7 +1741,8 @@ public class CcToolchainFeaturesTest extends FoundationTestCase { buildFeatures( "artifact_name_pattern {", "category_name: 'static_library'", - "pattern: 'some_pattern'}"); + "prefix: 'foo'", + "extension: 'bar'}"); toolchainFeatures.getArtifactNameForCategory(ArtifactCategory.DYNAMIC_LIBRARY, "output_name"); fail("Should throw InvalidConfigurationException."); } catch (InvalidConfigurationException e) { |