-
Notifications
You must be signed in to change notification settings - Fork 218
How do tests work, when we need to rely on resources? #123
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
Comments
How are you calculating your path? Via script? Directory.current should be the root of your project. |
Where does the temp folder come from, and how do my files get into that temp folder? |
Unfortunately, the resource loading logic can't make an assumption that a particular working directory is ever set. The resource loading logic needs to work with snapshots, pub run, pub serve, or from the command line. The platform.script is the "anchor", and from there I can look inside of packages/ for my resources. |
here is the logic for trying to find resources, compensating for all the ways we can run Dart code. Maybe it needs to compensate for the new test runner's conditions, too. https://github.com/dart-lang/dartdoc/blob/master/lib/resource_loader.dart This is ugly because Dart doesn't make guarantees here, unfortunately. |
@sethladd The temp dir is where we create the funky script that loads your test in an isolate. It's all internal to the test runner. |
What exactly is put into the temp dir? Just a "funky script"? Where can I learn more about this "funky script" ? Is there a document on how the test runner works (and what guarantees it makes, where files are put, how isolates are involved, etc) ? tldr: please help me understand what I can rely on, so I can find files in my lib/ dir of my project. The root issue is: my app needs to load files from within itself (currently, lib/). Thanks! |
Currently, browser tests can get resources from This is awkward and ad-hoc, which is why everyone's so excited about Lasse's proposal for a more uniform system. Such a system, supported by the core libraries, is necessary for having a means of loading resources that works well across all environments.
In general,
The code itself is documented. The exact manner in which the test file is invoked is considered an implementation detail, but roughly speaking:
We don't document that |
packages imports force the files into the |
I wrote up a quick SO question/answer for how to do it here: http://stackoverflow.com/questions/30465381/how-can-i-dynamically-construct-a-dart-script-for-spawnuri/30465382#30465382 |
I just tried upgrading from unittest to test. I'm now getting this error:
I am running this test via
pub run test
, as instructed.Where did this temp folder come from? And how can I get the entire contents of my lib/ folder into that temp folder?
Specifically, I have:
Thanks!
The text was updated successfully, but these errors were encountered: