Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.2.0] TargetPattern parsing fixes #17945

Merged
merged 5 commits into from
Apr 4, 2023
Merged

Commits on Mar 31, 2023

  1. Tests for TargetPattern parsing, and some sanity fixes

    - TargetPatternTest isn't testing much right now. This CL changes it to actually assert the result of parsing is as expected, and also test a few different parser setups (in main repo, with a relative directory, in a non-main repo).
      - This necessitated adding #toString methods to all TargetPattern subclasses.
      - Also rearranged the parameters in the constructors of all subclasses so that `originalPattern` is always the first parameter.
    - Removed the always-true `checkWildcardConflict` parameter in `TargetsInPackage`.
    - Removed the weak check before `interpretPathAsTarget` as it was not only weak, but wrong. It made parsing `Bar\\java` a failure at the repo root but a success in a subdirectory.
    
    Work towards #4385
    
    PiperOrigin-RevId: 520630430
    Change-Id: Icee98f38134fe274ba800d2e949c83f0ae18c247
    Wyverald committed Mar 31, 2023
    Configuration menu
    Copy the full SHA
    0770518 View commit details
    Browse the repository at this point in the history
  2. Switch TargetPattern.Parser to use LabelParser

    - Target patterns and labels have very similar syntax, yet are parsed completely separately. Furthermore, the code for target pattern parsing wasn't written with repos in mind, causing some corner cases such as #4385.
    - This CL augments LabelParser to deal with some syntax specific to target patterns (mostly the '...' thing), and switches TargetPattern.Parser to use LabelParser instead.
    - This fixes some inconsistencies between the two and eliminates the bug linked above.
    - Added LabelParserTest to make sure that the table in the javadoc of LabelParser.Parts#parse is actually accurate.
      - Switched LabelParser.Parts to use AutoValue instead to enable testing.
    - Some more cleanup in TargetPattern.Parser; removing outdated fields/methods/etc.
    
    Fixes #4385.
    
    RELNOTES: `@foo` labels can now be used on the command line as the top-level target (that is, `bazel build @foo` now works). Double-dot syntax is now forbidden (`bazel build ../foo` will no longer work).
    PiperOrigin-RevId: 520902549
    Change-Id: I38d6400381a3c4ac4c370360578702d5dd870909
    Wyverald committed Mar 31, 2023
    Configuration menu
    Copy the full SHA
    c8a4619 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9377524 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    24b001e View commit details
    Browse the repository at this point in the history

Commits on Apr 4, 2023

  1. Configuration menu
    Copy the full SHA
    38e9d12 View commit details
    Browse the repository at this point in the history