Invert static_link_test_srcs feature to dynamic_link_test_srcs.

The way the logic of the feature works at the moment, we can disable it globally but we can't enable it for specific rules because the global setting overrides the rule setting. We need to invert the feature to be able to enable it globally, but disable it locally for targets that don't work with the feature. Push back the retirement timeline for the experimental flag as well.

RELNOTES: None.
PiperOrigin-RevId: 232438035
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
index fc8e4e6..f8a2aec 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
@@ -96,12 +96,12 @@
   public static final String INTERMEDIATE_DWP_DIR = "_dwps";
 
   /**
-   * A string constant for the static_link_test_srcs feature.
+   * A string constant for the dynamic_link_test_srcs feature.
    *
-   * <p>Disabling this feature forces srcs of test executables to be linked dynamically in
+   * <p>Enabling this feature forces srcs of test executables to be linked dynamically in
    * DYNAMIC_MODE=AUTO.
    */
-  public static final String STATIC_LINK_TEST_SRCS = "static_link_test_srcs";
+  public static final String DYNAMIC_LINK_TEST_SRCS = "dynamic_link_test_srcs";
 
   /** Provider for native deps launchers. DO NOT USE. */
   @Deprecated
@@ -330,13 +330,13 @@
     // Allows the dynamic library generated for code of default dynamic mode targets to be linked
     // separately. The main use case for default dynamic mode is the cc_test rule. The same behavior
     // can also be enabled specifically for tests with an experimental flag.
-    // TODO(meikeb): Retire the experimental flag by end of 2018.
+    // TODO(meikeb): Retire the experimental flag in Q1 2019.
     boolean linkCompileOutputSeparately =
         ruleContext.isTestTarget()
             && linkingMode == LinkingMode.DYNAMIC
             && cppConfiguration.getDynamicModeFlag() == DynamicMode.DEFAULT
             && (cppConfiguration.getLinkCompileOutputSeparately()
-                || ruleContext.getDisabledFeatures().contains(STATIC_LINK_TEST_SRCS));
+                || ruleContext.getFeatures().contains(DYNAMIC_LINK_TEST_SRCS));
     // When linking the object files directly into the resulting binary, we do not need
     // library-level link outputs; thus, we do not let CcCompilationHelper produce link outputs
     // (either shared object files or archives) for a non-library link type [*], and add
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 740e44e..3392bfb 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
@@ -277,8 +277,7 @@
   }
 
   @Test
-  public void testCompilesDynamicModeTestSourcesWithoutFeatureIntoDynamicLibrary()
-      throws Exception {
+  public void testCompilesDynamicModeTestSourcesWithFeatureIntoDynamicLibrary() throws Exception {
     if (OS.getCurrent() == OS.WINDOWS) {
       // Skip the test on Windows.
       // TODO(bazel-team): maybe we should move that test that doesn't work with MSVC toolchain to
@@ -287,9 +286,9 @@
     }
     scratch.file(
         "x/BUILD",
-        "cc_test(name='a', srcs=['a.cc'], features=['-static_link_test_srcs'])",
+        "cc_test(name='a', srcs=['a.cc'], features=['dynamic_link_test_srcs'])",
         "cc_binary(name='b', srcs=['a.cc'])",
-        "cc_test(name='c', srcs=['a.cc'], features=['-static_link_test_srcs'], linkstatic=1)");
+        "cc_test(name='c', srcs=['a.cc'], features=['dynamic_link_test_srcs'], linkstatic=1)");
     scratch.file("x/a.cc", "int main() {}");
     useConfiguration("--force_pic");