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

dart test --help does not work without pubspec.yaml #55820

Closed
alexeyinkin opened this issue May 23, 2024 · 1 comment
Closed

dart test --help does not work without pubspec.yaml #55820

alexeyinkin opened this issue May 23, 2024 · 1 comment

Comments

@alexeyinkin
Copy link

When I run dart test --help in a directory without pubspec.yaml, I see this:

No pubspec.yaml file found - run this command in your project folder.

Usage: dart test [arguments]

Note: flags and options for this command are provided by the project's package:test dependency.
If package:test is not included as a dev_dependency in the project's pubspec.yaml, no flags or options will be listed.

Run "dart help" to see global options.

It's only with pubspec.yaml that it shows the expected reference. Also, it starts with resolving dependencies, which has side effects like creating pubspec.lock which I may not need. I expect it to only show the reference.

Output of resolving dependencies and the reference
Resolving dependencies in `/Users/ai/work/senior-dev/common_dart`... 
Downloading packages... 
Got dependencies in `/Users/ai/work/senior-dev/common_dart`.
Building package executable... (3.1s)
Built test:test.
Runs tests in this package.

Usage: dart test [files or directories...]

-h, --help                            Show this usage information.
    --version                         Show the package:test version.

Selecting Tests:
-n, --name                            A substring of the name of the test to run.
                                      Regular expression syntax is supported.
                                      If passed multiple times, tests must match all substrings.
-N, --plain-name                      A plain-text substring of the name of the test to run.
                                      If passed multiple times, tests must match all substrings.
-t, --tags                            Run only tests with all of the specified tags.
                                      Supports boolean selector syntax.
-x, --exclude-tags                    Don't run tests with any of the specified tags.
                                      Supports boolean selector syntax.
    --[no-]run-skipped                Run skipped tests instead of skipping them.

Running Tests:
-p, --platform                        The platform(s) on which to run the tests.
                                      [vm (default), chrome, firefox, safari, edge, node].
                                      Each platform supports the following compilers:
                                      [vm]: kernel (default), source, exe
                                      [chrome]: dart2js (default), dart2wasm
                                      [firefox]: dart2js (default), dart2wasm
                                      [safari]: dart2js (default)
                                      [edge]: dart2js (default)
                                      [node]: dart2js (default)
-c, --compiler                        The compiler(s) to use to run tests, supported compilers are [dart2js, dart2wasm, exe, kernel, source].
                                      Each platform has a default compiler but may support other compilers.
                                      You can target a compiler to a specific platform using arguments of the following form [<platform-selector>:]<compiler>.
                                      If a platform is specified but no given compiler is supported for that platform, then it will use its default compiler.
-P, --preset                          The configuration preset(s) to use.
-j, --concurrency=<threads>           The number of concurrent test suites run.
                                      (defaults to "4")
    --total-shards                    The total number of invocations of the test runner being run.
    --shard-index                     The index of this test runner invocation (of --total-shards).
    --timeout                         The default test timeout. For example: 15s, 2x, none
                                      (defaults to "30s")
    --ignore-timeouts                 Ignore all timeouts (useful if debugging)
    --pause-after-load                Pause for debugging before any tests execute.
                                      Implies --concurrency=1, --debug, and --ignore-timeouts.
                                      Currently only supported for browser tests.
    --debug                           Run the VM and Chrome tests in debug mode.
    --coverage=<directory>            Gather coverage and output it to the specified directory.
                                      Implies --debug.
    --[no-]chain-stack-traces         Use chained stack traces to provide greater exception details
                                      especially for asynchronous code. It may be useful to disable
                                      to provide improved test performance but at the cost of
                                      debuggability.
    --no-retry                        Don't rerun tests that have retry set.
    --test-randomize-ordering-seed    Use the specified seed to randomize the execution order of test cases.
                                      Must be a 32bit unsigned integer or "random".
                                      If "random", pick a random seed to use.
                                      If not passed, do not randomize test case execution order.
    --[no-]fail-fast                  Stop running tests after the first failure.

Output:
-r, --reporter=<option>               Set how to print test results.

          [compact] (default)         A single line, updated continuously.
          [expanded]                  A separate line for each update.
          [failures-only]             A separate line for failing tests with no output for passing tests
          [github]                    A custom reporter for GitHub Actions (the default reporter when running on GitHub Actions).
          [json]                      A machine-readable format (see https://dart.dev/go/test-docs/json_reporter.md).
          [silent]                    A reporter with no output. May be useful when only the exit code is meaningful.

    --file-reporter                   Enable an additional reporter writing test results to a file.
                                      Should be in the form <reporter>:<filepath>, Example: "json:reports/tests.json"
    --verbose-trace                   Emit stack traces with core library frames.
    --js-trace                        Emit raw JavaScript stack traces for browser tests.
    --[no-]color                      Use terminal colors.
                                      (auto-detected by default)
dart info
If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.

#### General info

- Dart 3.4.0 (stable) (Mon May 6 07:59:58 2024 -0700) on "macos_arm64"
- on macos / Version 13.6 (Build 22G120)
- locale is en-GE

#### Project info

- sdk constraint: '^3.3.0'
- dependencies: clock, json_annotation, model_interfaces
- dev_dependencies: build_runner, json_serializable, test

#### Process info

|  Memory |  CPU | Elapsed time | Command line                                                                               |
| ------: | ---: | -----------: | ------------------------------------------------------------------------------------------ |
|   32 MB | 0.0% |  05-17:59:41 | dart --enable-asserts --pause_isolates_on_start --enable-vm-service:51163 <path>/main.dart |
|   32 MB | 0.0% |  05-18:00:04 | dart --pause_isolates_on_start --enable-vm-service:51048 run test -r json <path>/main_test.dart |
|    9 MB | 0.0% |  61-11:23:49 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer |
|    8 MB | 0.0% |  36-16:07:15 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer |
|    8 MB | 0.0% | 226-13:10:59 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer |
|   10 MB | 0.0% | 229-12:08:32 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer |
|   14 MB | 0.0% |  07-12:20:31 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer |
|   41 MB | 0.0% |     12:45:59 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer |
| 1130 MB | 0.0% |     11:58:02 | dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer |
|   45 MB | 0.0% |     13:22:48 | flutter_tools.snapshot daemon                                                              |
|   42 MB | 0.0% |     13:22:48 | flutter_tools.snapshot daemon                                                              |
@lrhn
Copy link
Member

lrhn commented May 23, 2024

The printed lines

Note: flags and options for this command are provided by the project's package:test dependency.
If package:test is not included as a dev_dependency in the project's pubspec.yaml, no flags or options will be listed

says that this is the expected behavior.

The test functionality is not built into the dart executable or the Dart SDK, but it's provided by a package that the dart utility invokes.
That's a deliberate choice because it allows the test package to be versioned independently of the SDK.

That's also why running dart test implies resolving dependencies, it's literally asking for a package to be available.

@alexeyinkin alexeyinkin closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants