Skip to content

Commit

Permalink
Add # support for LabelValidator as discussed in #2006
Browse files Browse the repository at this point in the history
As suggested by @damienmg in #2006 send this out to run it with internal test.

Closes #2059 .

Progress towards #374.

--
Reviewed-on: #2059
MOS_MIGRATED_REVID=139562084
  • Loading branch information
mzh0 authored and meteorcloudy committed Nov 18, 2016
1 parent 82179a1 commit 84a3ed9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,16 @@

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.CharMatcher;

import java.util.Objects;

import javax.annotation.Nullable;

/**
* The canonical place to parse and validate Blaze labels.
*/
public final class LabelValidator {

/**
* Matches punctuation in target names which requires quoting in a blaze query.
*/
private static final CharMatcher PUNCTUATION_REQUIRING_QUOTING = CharMatcher.anyOf("+,=~");
/** Matches punctuation in target names which requires quoting in a blaze query. */
private static final CharMatcher PUNCTUATION_REQUIRING_QUOTING = CharMatcher.anyOf("+,=~#");

/**
* Matches punctuation in target names which doesn't require quoting in a blaze query.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static org.junit.Assert.fail;

import com.google.devtools.build.lib.cmdline.LabelValidator.PackageAndTarget;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down Expand Up @@ -96,6 +95,7 @@ public void testValidateTargetName() throws Exception {
assertNull(LabelValidator.validateTargetName("foo.bar"));
assertNull(LabelValidator.validateTargetName("foo@bar"));
assertNull(LabelValidator.validateTargetName("foo~bar"));
assertNull(LabelValidator.validateTargetName("foo#bar"));

assertEquals("target names may not end with '/'",
LabelValidator.validateTargetName("foo/"));
Expand Down

0 comments on commit 84a3ed9

Please sign in to comment.