Skip to content

Commit

Permalink
Allow digits in action_configs' and features' names
Browse files Browse the repository at this point in the history
Work towards issue #5380
RELNOTES: None.
PiperOrigin-RevId: 223946963
  • Loading branch information
scentini authored and Copybara-Service committed Dec 4, 2018
1 parent 798b9a9 commit 8fbd36d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'])]",
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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'");
}
}

Expand Down Expand Up @@ -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'], "
Expand Down Expand Up @@ -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'");
}

Expand All @@ -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");
}
}

Expand Down

0 comments on commit 8fbd36d

Please sign in to comment.