diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java index 5c987c243e5181..0271c48487e2fe 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java @@ -1551,12 +1551,12 @@ static Feature featureFromSkylark(SkylarkInfo featureStruct) "A feature must either have a nonempty 'name' field or be enabled."); } - if (!name.matches("^[_a-z+\\-]*$")) { + if (!name.matches("^[_a-z0-9+\\-]*$")) { throw new EvalException( featureStruct.getCreationLoc(), String.format( - "A feature's name must consist solely of lowercase ASCII letters, '_', '+', and '-', " - + "got '%s'", + "A feature's name must consist solely of lowercase ASCII letters, digits, '_', '+', " + + "and '-', got '%s'", name)); } @@ -1852,12 +1852,12 @@ static ActionConfig actionConfigFromSkylark(SkylarkInfo actionConfigStruct) actionConfigStruct.getCreationLoc(), "The 'action_name' field of action_config must be a nonempty string."); } - if (!actionName.matches("^[_a-z+\\-]*$")) { + if (!actionName.matches("^[_a-z0-9+\\-]*$")) { throw new EvalException( actionConfigStruct.getCreationLoc(), String.format( - "An action_config's name must consist solely of lowercase ASCII letters, '_', '+', " - + "and '-', got '%s'", + "An action_config's name must consist solely of lowercase ASCII letters, digits, '_'," + + " '+', and '-', got '%s'", actionName)); } diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java index 28395fd579d050..8338f906f9cf16 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java @@ -3350,7 +3350,7 @@ public void testActionConfig() throws Exception { createActionConfigRule( "eight", - /* actionName= */ "'actionname_++-'", + /* actionName= */ "'actionname32_++-'", /* enabled= */ "True", /* tools= */ "[tool(path = 'a/b/c')]", /* flagSets= */ "[flag_set(actions = ['a', 'b'])]", @@ -3361,7 +3361,7 @@ public void testActionConfig() throws Exception { assertThat(actionConfigStruct).isNotNull(); ActionConfig a = CcModule.actionConfigFromSkylark(actionConfigStruct); assertThat(a).isNotNull(); - assertThat(a.getActionName()).isEqualTo("actionname_++-"); + assertThat(a.getActionName()).isEqualTo("actionname32_++-"); assertThat(a.getImplies()).containsExactly("a", "b").inOrder(); createActionConfigRule( @@ -3383,7 +3383,7 @@ public void testActionConfig() throws Exception { .hasMessageThat() .contains( "An action_config's name must consist solely " - + "of lowercase ASCII letters, '_', '+', and '-', got 'Upper'"); + + "of lowercase ASCII letters, digits, '_', '+', and '-', got 'Upper'"); } createActionConfigRule( @@ -3405,7 +3405,7 @@ public void testActionConfig() throws Exception { .hasMessageThat() .contains( "An action_config's name must consist solely " - + "of lowercase ASCII letters, '_', '+', and '-', got 'white\tspace'"); + + "of lowercase ASCII letters, digits, '_', '+', and '-', got 'white\tspace'"); } } @@ -3701,7 +3701,7 @@ public void testFeature() throws Exception { createFeatureRule( "eight", - /* name= */ "'featurename+-_'", + /* name= */ "'featurename32+-_'", /* enabled= */ "True", /* flagSets= */ "[flag_set(actions = ['a'], flag_groups = [flag_group(flags = ['a'])])]", /* envSets= */ "[env_set(actions = ['a1'], " @@ -3736,7 +3736,7 @@ public void testFeature() throws Exception { assertThat(ee) .hasMessageThat() .contains( - "A feature's name must consist solely of lowercase ASCII letters, " + "A feature's name must consist solely of lowercase ASCII letters, digits, " + "'_', '+', and '-', got 'UpperCase'"); } @@ -3761,7 +3761,7 @@ public void testFeature() throws Exception { .hasMessageThat() .contains( "A feature's name must consist solely of " - + "lowercase ASCII letters, '_', '+', and '-', got 'white space"); + + "lowercase ASCII letters, digits, '_', '+', and '-', got 'white space"); } }