Skip to content
Snippets Groups Projects
Commit 3d978772 authored by nweiz@google.com's avatar nweiz@google.com Committed by Natalie Weizenbaum
Browse files

Properly pass environment variables from pub to dart2js.

R=rnystrom@google.com
BUG=16298

Review URL: https://codereview.chromium.org//136003018

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge@32144 260f80e4-7a28-3924-810f-c04153c831b5
parent 79db5787
No related branches found
No related tags found
No related merge requests found
...@@ -72,12 +72,7 @@ Future compile(String entrypoint, CompilerProvider provider, { ...@@ -72,12 +72,7 @@ Future compile(String entrypoint, CompilerProvider provider, {
if (terse) options.add('--terse'); if (terse) options.add('--terse');
if (toDart) options.add('--output-type=dart'); if (toDart) options.add('--output-type=dart');
if (environment != null) { if (environment == null) environment = {};
environment.forEach((name, value) {
options.add('-D$name=$value');
});
}
if (commandLineOptions != null) options.addAll(commandLineOptions); if (commandLineOptions != null) options.addAll(commandLineOptions);
if (packageRoot == null) { if (packageRoot == null) {
...@@ -91,7 +86,8 @@ Future compile(String entrypoint, CompilerProvider provider, { ...@@ -91,7 +86,8 @@ Future compile(String entrypoint, CompilerProvider provider, {
provider.provideInput, provider.provideInput,
provider.handleDiagnostic, provider.handleDiagnostic,
options, options,
provider.provideOutput)); provider.provideOutput,
environment));
}); });
} }
......
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library pub_tests;
import 'package:scheduled_test/scheduled_test.dart';
import '../../descriptor.dart' as d;
import '../../test_pub.dart';
import '../../serve/utils.dart';
main() {
initConfig();
integration("passes along environment constants", () {
d.dir(appPath, [
d.pubspec({
"name": "myapp",
"transformers": [{
"\$dart2js": {"environment": {'CONSTANT': 'true'}}
}]
}),
d.dir("web", [
d.file("main.dart", """
void main() {
if (const bool.fromEnvironment('CONSTANT')) {
print("hello");
}
}
""")
])
]).create();
pubServe();
requestShouldSucceed("main.dart.js", contains("hello"));
endPubServe();
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment