dart-lang / test

A library for writing unit tests in Dart.
https://pub.dev/packages/test
495 stars 214 forks source link

[WIP] Add suitePath getter #2281

Open jakemac53 opened 2 months ago

jakemac53 commented 2 months ago

Possible resolution to https://github.com/dart-lang/test/issues/110.

Adds a suitePath getter which gives the package relative path to the current suite if it is available.

I also expanded the test coverage in test_api to VM/chrome and all compilers, just to ensure this works everywhere.

github-actions[bot] commented 2 months ago

PR Health

Changelog Entry :heavy_check_mark: | Package | Changed Files | | :--- | :--- | Changes to files need to be [accounted for](https://github.com/dart-lang/ecosystem/wiki/Changelog) in their respective changelogs.
Package publish validation :heavy_check_mark: | Package | Version | Status | | :--- | ---: | :--- | | package:checks | 0.3.1-wip | WIP (no publish necessary) | | package:test | 1.25.9-wip | WIP (no publish necessary) | | package:test_api | 0.7.4-wip | WIP (no publish necessary) | | package:test_core | 0.6.6-wip | WIP (no publish necessary) | Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.
natebosch commented 2 months ago

@matanlurey would you be able to put together a prototype of your intended usage so we can confirm whether this solves the problem?

jakemac53 commented 2 months ago

This is only meant to solve the original problem stated in https://github.com/dart-lang/test/issues/110, which is getting the path to the test script. It does not help with getting access to the package root, but Uri.base does already give you that (whenever using the test runner).

natebosch commented 2 months ago

but Uri.base does already give you that

Does this get impacted by changes to the working directory?

jakemac53 commented 2 months ago

Does this get impacted by changes to the working directory?

Probably, although I don't know for sure. But, that is partially why I like just exposing the relative suite path. We can be out of the business of the rest of it, which isn't really in our control. We can provide suggestions with caveats (like using Uri.base), which will work for most, but we don't guarantee them or support them directly.