swiftlang / swift-testing

A modern, expressive testing package for Swift
Apache License 2.0
1.72k stars 72 forks source link

Request for the ability to run tests in a Package with a given tag from the command line #591

Open dimsumthinking opened 1 month ago

dimsumthinking commented 1 month ago

Description

When running tests for a package from the command-line using swift test I'd love a flag that allows me to run the tests for a given tag.

It would also be nice to be able to write more complicated predicates so that I could run them for:

tag1. (just those whose tags include tag1) ~tag1 or !tag1 (all items who's tags do not include tag1) no-tags (any untagged item) tag1 & tag2 (must be tagged with both) tag1 | tag2 (must be tagged with either)

Sorry if this is too vague - but I had to give up on the command line at the point that I just wanted to run tests for a given tag.

Expected behavior

No response

Actual behavior

No response

Steps to reproduce

No response

swift-testing version/commit hash

No response

Swift & OS version (output of swift --version && uname -a)

No response

grynspan commented 1 month ago

It wouldn't be impossible to amend the existing --filter and --skip arguments to take tags so long as they're syntactically distinguishable from regular expressions representing (potentially partial) test IDs.

For instance, if we required a prefix tag:, that would not represent a valid test ID as no test ID should start with that prefix:

swift test --filter tag:critical

(This would also serve to automagically filter out all XCTest tests as no XCTest test ID can start with that string either.)

It wouldn't give us full boolean logic on tags, but building out what is effectively a parser/lexer just for parsing tags may be overkill.

dimsumthinking commented 1 month ago

Thank you

using filter or skip the way you describe would certainly meet my needs.

grynspan commented 1 month ago

Tracked internally by rdar://132989780.