test icon indicating copy to clipboard operation
test copied to clipboard

[WIP] Add suitePath getter

Open jakemac53 opened this issue 1 year ago • 5 comments

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.

  • Only works in the test runner itself (we could maybe support some other scenarios if we wanted, using Platform.script on the VM and Uri.base on the web).
  • On the web, Uri.base already actually contains the full path including the suite, so you don't want to use this there which is a bit weird. On the VM you want to do something like Uri.base.resolve(suitePath).resolve(<some-suite-relative-path>).
    • We could consider instead providing a function for resolving suite relative paths, or make this API give you the absolute path to the suite (which would be an http URI on the web).
    • We could also add a <base> tag to the html page, setting it to be the package root.

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

jakemac53 avatar Sep 11 '24 21:09 jakemac53

PR Health

Changelog Entry :heavy_check_mark:
Package Changed Files

Changes to files need to be accounted for 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.

github-actions[bot] avatar Sep 11 '24 21:09 github-actions[bot]

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

natebosch avatar Sep 12 '24 21:09 natebosch

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).

jakemac53 avatar Sep 13 '24 14:09 jakemac53

but Uri.base does already give you that

Does this get impacted by changes to the working directory?

natebosch avatar Sep 13 '24 18:09 natebosch

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.

jakemac53 avatar Sep 13 '24 19:09 jakemac53