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

Workspace support for dart test? #2279

Open
jakemac53 opened this issue Sep 10, 2024 · 4 comments
Open

Workspace support for dart test? #2279

jakemac53 opened this issue Sep 10, 2024 · 4 comments

Comments

@jakemac53
Copy link
Contributor

We could consider running all tests in the workspace, if running dart test from the workspace root.

Some high level thoughts:

  • We might want to guard this behind a flag, --recursive or similar. The workspace root also might have its own tests and otherwise we can't tell the difference between user intents.
  • Not all packages in a repo have to be a part of a workspace, so people might get confused (removing a package from the workspace makes dart test from the root not run its tests).
    • We could mitigate this by explicitly listing the packages whose tests we are running.
  • There might be other edge cases based on other logic that assumes the current working directory is the package. We could change the working dir before running tests in each package, but that might be too magical.

Maybe this should be the job of a different tool - like pub 🤣 (but more realistically the dart tool).

@matanlurey
Copy link
Contributor

Some thoughts:

  • We might want to guard this behind a flag, --recursive or similar. The workspace root also might have its own tests

Seems reasonable to me. This is a command probably more likely used either on CI, or pre-CI, not edit-refresh cycle.

Not all packages in a repo have to be a part of a workspace

Less concerned, particularly if we do dart test --recursive (or dart test --workspace?)

  • There might be other edge cases based on other logic that assumes the current working directory is the package

This is definitely true.

I find in my own tests the inability to rely on Platform.currentScript (?) with pkg/test makes it very hard to read relative files on disk, and I'm guessing many many apps (my own included) make assumptions around CWD. If pkg/test exposed some sort of environment variable or -D that could be used for this purpose at least there is a migration path?

@jakemac53
Copy link
Contributor Author

Less concerned, particularly if we do dart test --recursive (or dart test --workspace?)

I like --workspace that is a lot more clear 👍

@jakemac53
Copy link
Contributor Author

jakemac53 commented Sep 10, 2024

I find in my own tests the inability to rely on Platform.currentScript (?) with pkg/test makes it very hard to read relative files on disk, and I'm guessing many many apps (my own included) make assumptions around CWD. If pkg/test exposed some sort of environment variable or -D that could be used for this purpose at least there is a migration path?

I think a general purpose API of some sort is best here, it has been discussed for quite some time without resolution though #110. A -D variable wouldn't work when running tests in an isolate, because while an environment is allowed to be passed, it is not supported. It would also prevent us from sharing compilation across tests.

@matanlurey
Copy link
Contributor

Thanks, I will leave a comment on that issue.

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