Index: dart/tools/testing/dart/compiler_configuration.dart |
diff --git a/dart/tools/testing/dart/compiler_configuration.dart b/dart/tools/testing/dart/compiler_configuration.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a7e6a9fa6987982ea54b6156d70e2453b844caca |
--- /dev/null |
+++ b/dart/tools/testing/dart/compiler_configuration.dart |
@@ -0,0 +1,81 @@ |
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS 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 compiler_configuration; |
+ |
+abstract class CompilerConfiguration { |
+ // TODO(ahe): Remove this constructor and move the switch to |
+ // test_options.dart. We probably want to store an instance of |
+ // [CompilerConfiguration] in [configuration] there. |
+ factory CompilerConfiguration(Map configuration) { |
+ String compiler = configuration['compiler']; |
+ switch (compiler) { |
+ case 'dartanalyzer': |
+ case 'dart2analyzer': |
+ return new AnalyzerCompilerConfiguration(); |
+ case 'dart2js': |
+ return new Dart2jsCompilerConfiguration(); |
+ case 'dart2dart': |
+ return new Dart2dartCompilerConfiguration(); |
+ case 'none': |
+ return new NoneCompilerConfiguration(); |
+ default: |
+ throw "Unknown compiler '$compiler'"; |
+ } |
+ } |
+ |
+ CompilerConfiguration._subclass(); |
+ |
+ /// Return a multiplier used to give tests longer time to run. |
+ int computeTimeoutMultiplier({ |
+ bool isDebug: false, |
+ bool isChecked: false, |
+ bool isHostChecked: false}) { |
+ return 1; |
+ } |
+} |
+ |
+/// The "none" compiler. |
+class NoneCompilerConfiguration extends CompilerConfiguration { |
+ NoneCompilerConfiguration() |
+ : super._subclass(); |
+} |
+ |
+/// Common configuration for dart2js-based tools, such as, dart2js and |
+/// dart2dart. |
+class Dart2xCompilerConfiguration extends CompilerConfiguration { |
+ Dart2xCompilerConfiguration() |
+ : super._subclass(); |
+} |
+ |
+/// Configuration for dart2js compiler. |
+class Dart2jsCompilerConfiguration extends Dart2xCompilerConfiguration { |
+ int computeTimeoutMultiplier({ |
+ bool isDebug: false, |
+ bool isChecked: false, |
+ bool isHostChecked: false}) { |
+ int multiplier = 1; |
+ if (isDebug) multiplier *= 4; |
+ if (isChecked) multiplier *= 2; |
+ if (isHostChecked) multiplier *= 16; |
+ return multiplier; |
+ } |
+} |
+ |
+/// Configuration for dart2dart compiler. |
+class Dart2dartCompilerConfiguration extends Dart2xCompilerConfiguration { |
+} |
+ |
+/// Common configuration for analyzer-based tools, such as, dartanalyzer. |
+class AnalyzerCompilerConfiguration extends CompilerConfiguration { |
+ AnalyzerCompilerConfiguration() |
+ : super._subclass(); |
+ |
+ int computeTimeoutMultiplier({ |
+ bool isDebug: false, |
+ bool isChecked: false, |
+ bool isHostChecked: false}) { |
+ return 4; |
+ } |
+} |