Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Unified Diff: lib/src/executable.dart

Issue 1829483002: Add support for a global configuration file. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « doc/package_config.md ('k') | lib/src/runner/configuration.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/executable.dart
diff --git a/lib/src/executable.dart b/lib/src/executable.dart
index c065bffd3a4f2b16d6b6575772701892bd957235..cb8547eb08fdcb164bca93000e08038fd74ab2c0 100644
--- a/lib/src/executable.dart
+++ b/lib/src/executable.dart
@@ -7,6 +7,7 @@
// bin.
import 'dart:io';
+import 'package:path/path.dart' as p;
import 'package:source_span/source_span.dart';
import 'package:stack_trace/stack_trace.dart';
import 'package:yaml/yaml.dart';
@@ -59,6 +60,17 @@ bool get _usesTransformer {
});
}
+/// Returns the path to the global test configuration file.
+final String _globalConfigPath = (){
+ if (Platform.environment.containsKey('DART_TEST_CONFIG')) {
+ return Platform.environment['DART_TEST_CONFIG'];
+ } else if (Platform.operatingSystem == 'windows') {
+ return p.join(Platform.environment['LOCALAPPDATA'], 'DartTest.yaml');
+ } else {
+ return '${Platform.environment['HOME']}/.dart_test.yaml';
+ }
+}();
+
main(List<String> args) async {
var configuration;
try {
@@ -86,10 +98,18 @@ main(List<String> args) async {
}
try {
+ var fileConfiguration = Configuration.empty;
+ if (new File(_globalConfigPath).existsSync()) {
+ fileConfiguration = fileConfiguration.merge(
+ new Configuration.load(_globalConfigPath, global: true));
+ }
+
if (new File("dart_test.yaml").existsSync()) {
- var fileConfiguration = new Configuration.load("dart_test.yaml");
- configuration = fileConfiguration.merge(configuration);
+ fileConfiguration = fileConfiguration.merge(
+ new Configuration.load("dart_test.yaml"));
}
+
+ configuration = fileConfiguration.merge(configuration);
} on SourceSpanFormatException catch (error) {
stderr.writeln(error.toString(color: configuration.color));
exitCode = exit_codes.data;
« no previous file with comments | « doc/package_config.md ('k') | lib/src/runner/configuration.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698