diff options
author | kush <kush@google.com> | 2017-09-06 20:49:57 +0200 |
---|---|---|
committer | Yun Peng <pcloudy@google.com> | 2017-09-07 09:57:35 +0200 |
commit | 9b6cf941461769becc06e30d4fd0c2007066abbd (patch) | |
tree | 62ea236941f1b490278278432179c33bcaa4f0c9 /src/test/java/com/google/devtools/build/lib/rules/cpp | |
parent | 35e0c2d716de87ce746b87098b92d81840255495 (diff) |
Internal change
PiperOrigin-RevId: 167751263
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/rules/cpp')
4 files changed, 11 insertions, 87 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java index 469e51d6e7..67b9f8a0e2 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariablesTest.java @@ -20,7 +20,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.Artifact; -import com.google.devtools.build.lib.analysis.util.AnalysisMock; import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Variables; import org.junit.Test; @@ -66,49 +65,15 @@ public class CompileBuildVariablesTest extends BuildViewTestCase { } @Test - public void testPresenceOfLegacyCompileFlags() throws Exception { - AnalysisMock.get().ccSupport().setupCrosstool(mockToolsConfig, "cxx_flag: '-foo'"); - useConfiguration(); - - scratch.file("x/BUILD", "cc_binary(name = 'bin', srcs = ['bin.cc'])"); - scratch.file("x/bin.cc"); - - Variables variables = getCompileBuildVariables("//x:bin", "bin"); - - ImmutableList<String> copts = - Variables.toStringList(variables, CppModel.LEGACY_COMPILE_FLAGS_VARIABLE_NAME); - assertThat(copts).contains("-foo"); - } - - @Test - public void testPresenceOfUserCompileFlags() throws Exception { - AnalysisMock.get().ccSupport().setupCrosstool(mockToolsConfig); - useConfiguration(); - - scratch.file("x/BUILD", "cc_binary(name = 'bin', srcs = ['bin.cc'], copts = ['-foo'])"); + public void testPresenceOfCoptsVariable() throws Exception { + scratch.file( + "x/BUILD", "cc_binary(name = 'bin', srcs = ['bin.cc'], copts = ['-foo', '-bar'])"); scratch.file("x/bin.cc"); Variables variables = getCompileBuildVariables("//x:bin", "bin"); ImmutableList<String> copts = - Variables.toStringList(variables, CppModel.USER_COMPILE_FLAGS_VARIABLE_NAME); - assertThat(copts).contains("-foo"); - } - - @Test - public void testPresenceOfUnfilteredCompileFlags() throws Exception { - AnalysisMock.get() - .ccSupport() - .setupCrosstool(mockToolsConfig, "unfiltered_cxx_flag: '--i_ll_live_forever'"); - useConfiguration(); - - scratch.file("x/BUILD", "cc_binary(name = 'bin', srcs = ['bin.cc'])"); - scratch.file("x/bin.cc"); - - Variables variables = getCompileBuildVariables("//x:bin", "bin"); - - ImmutableList<String> unfilteredCompileFlags = - Variables.toStringList(variables, CppModel.UNFILTERED_COMPILE_FLAGS_VARIABLE_NAME); - assertThat(unfilteredCompileFlags).contains("--i_ll_live_forever"); + Variables.toStringList(variables, CppModel.COPTS_VARIABLE_VALUE); + assertThat(copts).containsExactly("-foo", "-bar").inOrder(); } } diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLineTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLineTest.java index f481f0aa3b..97abeeb722 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLineTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLineTest.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.rules.cpp; import static com.google.common.truth.Truth.assertThat; import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.Root; @@ -25,7 +26,6 @@ import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfig import com.google.devtools.build.lib.rules.cpp.CompileCommandLine.Builder; import com.google.devtools.build.lib.rules.cpp.CppCompileAction.DotdFile; import java.io.IOException; -import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -97,47 +97,6 @@ public class CompileCommandLineTest extends BuildViewTestCase { .contains("-some_foo_flag"); } - @Test - public void testUnfilteredFlagsAreNotFiltered() throws Exception { - List<String> actualCommandLine = - getCompileCommandLineWithCoptsFilter(CppRuleClasses.UNFILTERED_COMPILE_FLAGS_FEATURE_NAME); - assertThat(actualCommandLine).contains("-i_am_a_flag"); - } - - @Test - public void testNonUnfilteredFlagsAreFiltered() throws Exception { - List<String> actualCommandLine = getCompileCommandLineWithCoptsFilter("filtered_flags"); - assertThat(actualCommandLine).doesNotContain("-i_am_a_flag"); - } - - private List<String> getCompileCommandLineWithCoptsFilter(String featureName) throws Exception { - CompileCommandLine compileCommandLine = - makeCompileCommandLineBuilder() - .setFeatureConfiguration( - getMockFeatureConfiguration( - "", - "action_config {", - " config_name: 'c++-compile'", - " action_name: 'c++-compile'", - " implies: '" + featureName + "'", - " tool {", - " tool_path: 'foo/bar/DUMMY_COMPILER'", - " }", - "}", - "feature {", - " name: '" + featureName + "'", - " flag_set {", - " action: 'c++-compile'", - " flag_group {", - " flag: '-i_am_a_flag'", - " }", - " }", - "}")) - .setCoptsFilter(flag -> !flag.contains("i_am_a_flag")) - .build(); - return compileCommandLine.getArgv(scratchArtifact("a/FakeOutput").getExecPath(), null); - } - private Builder makeCompileCommandLineBuilder() throws Exception { ConfiguredTarget dummyTarget = scratchConfiguredTarget("a", "a", "cc_binary(name='a', srcs=['a.cc'])"); @@ -151,6 +110,7 @@ public class CompileCommandLineTest extends BuildViewTestCase { return true; } }, + ImmutableList.<String>of(), "c++-compile", getTargetConfiguration().getFragment(CppConfiguration.class), new DotdFile(scratchArtifact("a/dotD")), diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java index 19f4392273..bc2e57f63f 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java @@ -84,14 +84,13 @@ public class CppLinkActionTest extends BuildViewTestCase { return CcToolchainFeaturesTest.buildFeatures( CppActionConfigs.getCppActionConfigs( CppPlatform.LINUX, - ImmutableSet.of(), + ImmutableSet.<String>of(), "gcc_tool", "dynamic_library_linker_tool", "ar_tool", "strip_tool", - /* supportsEmbeddedRuntimes= */ true, - /* supportsInterfaceSharedLibraries= */ false), - CppActionConfigs.getFeaturesToAppearLastInToolchain(ImmutableSet.of())) + true, + false)) .getFeatureConfiguration( FeatureSpecification.create( ImmutableSet.of( diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java index f2df3dd4b1..c0a24572ff 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CrosstoolConfigurationLoaderTest.java @@ -527,7 +527,7 @@ public class CrosstoolConfigurationLoaderTest extends AnalysisTestCase { "cxx-flag-A-1", "cxx-flag-A-2", "cxx-fastbuild-flag-A-1", "cxx-fastbuild-flag-A-2") .inOrder(); assertThat(ccProviderA.getUnfilteredCompilerOptions(NO_FEATURES)) - .containsExactly("unfiltered-flag-A-1", "unfiltered-flag-A-2") + .containsExactly("--sysroot=some", "unfiltered-flag-A-1", "unfiltered-flag-A-2") .inOrder(); assertThat(toolchainA.getDynamicLinkOptions(NO_FEATURES, true)) .containsExactly( |