dart-lang / dart-lang/test

Add the ability to get the current script or project path when using the new test runner

Open
#110 41 comments 5 reactions 0 assignees View on GitHub
type-enhancement
Dominant language
Dart
Stars
536
Forks
232
Avg merge
1d 10h
Merged PRs (30d)
10

Description

http://stackoverflow.com/questions/30214563/get-current-script-path-or-current-project-path-using-new-test-runner
I am porting old vm unittest files using the new test package. Some relies on input files in sub directories of my test folder. Before I was using Platform.script to find the location of such files. This works fine when using

```
$ dart test/my_test.dart
```

However using

```
$ pub run test
```

this is now pointing to a temp folder (tmp/dart_test_xxxx/runInIsolate.dart). I am unable to locate my test input files anymore. I cannot rely on the current path as I might run the test from a different working directory.

Is there a way to find the location of my_test.dart (or event the project root path), from which I could derive the locations of my files?

Contributor guide

Open the contributing guide

Research direction

Start by reading the new test runner entry point invoked by `pub run test` and compare its behavior with `dart test/my_test.dart`. Investigate how `Platform.script` becomes `tmp/dart_test_xxxx/runInIsolate.dart`, using `my_test.dart` and the referenced Stack Overflow question as context. Done means tests can reliably locate files relative to the test script or project without depending on the working directory.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.