-
Notifications
You must be signed in to change notification settings - Fork 215
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
Cannot access environment on dart test #1794
Comments
Should work according to #1509, but indeed does not work. Must be a regression. /cc @bkonyi @natebosch |
It seems it doesn't pick up any environment variables, either. |
You can get back to the old behavior with the flag With the new strategy we might need to build support for parsing the arguments as passed to the test runner. If we did that we'd probably want it to be general and work for dart2js tests as well. cc @jakemac53 |
Confirmed on my machine that It still doesn't pick up any environment variables, though. So If I do MY_VAR=true import 'dart:io' show Platform;
void main() {
print(Platform.environment['MY_VAR']);
}
|
I can't repro. Either strategy picks up the environment for me. Are you confident that the environment for the |
My bad, I didn't export the env var. After I did, it works. |
I don't see this as a high priority feature personally, and adding |
Hello, I have an issue I believe to be closely related to this. I am trying to test the following code on Mac (arm64), dart 3.6.0: import 'package:test/test.dart';
void main() {
final constString = const String.fromEnvironment("STRING");
final nonConstString = String.fromEnvironment("STRING");
print(" '$constString' != '$nonConstString' ");
test("blank test", () {});
} It seemed that (nearly) no matter how I run this, I tried:
After coming across this thread I tried running using the
Hopefully this is also useful for you all. |
The The non-const constructor is a runtime lookup which works for the kernel compiler at least - because we still spawn the pre-compiled kernel file as a sub-isolate of the test runner isolate, so at runtime the value does exist. I doubt either of these solutions would work with the |
dart -Dblah=true test
outputs:It seems like the environment does not exist when you run
dart test
Dart SDK 2.18.4
The text was updated successfully, but these errors were encountered: