Skip to content

buck test --include foo //... confusingly silently skips all tests #1243

@lf-

Description

@lf-

Description

When using buck test with the --include flag, the position of the flag relative to the target pattern affects whether tests are matched.

This is probably intentional behaviour but it is extremely confusing and merits a warning at minimum (and quite possibly revision).

Setup

Create a directory //foobar in this repo:

BUCK:

sh_test(
    name = "test_with_label",
    test = "test.sh",
    labels = ["some_test_label"],
)

sh_test(
    name = "test_without_label",
    test = "test.sh",
)

test.sh:

#!/bin/bash
# Simple passing test
exit 0

Reproduction

Repro'd on: a72a88b

Weird: Flag before target pattern (matches no tests)

cargo run -p buck2 -- test --include some_test_label //foobar/...
Tests finished: Pass 0. Fail 0. Fatal 0. Skip 0. Omit 0. Infra Failure 0. Build failure 0
NO TESTS RAN

Working: Flag after target pattern

cargo run -p buck2 -- test //foobar/... --include some_test_label
✓ Pass: gh_facebook_buck2//foobar:test_with_label (0.1s)
Tests finished: Pass 1. Fail 0. Fatal 0. Skip 0. Omit 0. Infra Failure 0. Build failure 0

Verification

I didn't goof up the labels AFAIK:

cargo run -p buck2 -- uquery //foobar:test_with_label --output-attribute labels
{
  "gh_facebook_buck2//foobar:test_with_label": {
    "labels": [
      "some_test_label"
    ]
  }
}

Expected Behavior

Either:

  • Both commands should produce the same result
  • The one that silently does the surprising thing of skipping all tests should print a warning

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions