Skip to content

swift test list does not fail with unrecognized argument swift test options.  #8069

Open
@bkhouri

Description

@bkhouri

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, swift build, swift test, swift package etc.

Description

swift test list command does not error when an unsupported argument is provided

The command line help for swift test list is

❯ swift test list --help     
OVERVIEW: Lists test methods in specifier format

USAGE: swift test list [--skip-build] [--enable-xctest] [--disable-xctest] [--enable-swift-testing] [--disable-swift-testing]

OPTIONS:
  --skip-build            Skip building the test target
  --enable-xctest/--disable-xctest
                          Enable support for XCTest
  --enable-swift-testing/--disable-swift-testing
                          Enable support for Swift Testing
  --version               Show the version.
  -h, -help, --help       Show help information.

However, running swift test list --filter foo does not error, while swift test list --unsupported-argument does.

Expected behavior

swift test list command line should either:

  • accept the swift test command line option and reflect said option in the output
  • error when the options do not match the swift test list --help

Actual behavior

swim test list currently accepts option from swift test but it not reflected in the output.

Steps to reproduce

Clone the repository

set -x
swift build
bin_path=$(swift build  --show-bin-path)
build_runner="${bin_path}/swift-build"
test_runner="${bin_path}/swift-test"

# build the repo to avoid compile warnings with the first `swift test list`
${build_runner}

# display the help to see a list of options
${test_runner} list --help


# display the actual tests returned by `grep` vs `--filter`
${test_runner} list | grep "WorkspaceTests"
${test_runner} list --filter "WorkspaceTests"

# Get a estimate of the number of tests returned by `grep` vs `--filter`
${test_runner} list | grep  "WorkspaceTests" | wc -l
${test_runner} list  --filter "WorkspaceTests" | wc -l

# Specify an argument that does not exist on `swift test` and it fails as expected
${test_runner} --non-existing-argument

set +x

Swift Package Manager version/commit hash

5efd210 (branch main)

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugswift testChanges impacting `swift test` tool

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions