| OLD | NEW |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library test.fletch_warnings_suite; | 5 library test.dartino_warnings_suite; |
| 6 | 6 |
| 7 import 'dart:io' as io; | 7 import 'dart:io' as io; |
| 8 | 8 |
| 9 import 'dart:convert' show | 9 import 'dart:convert' show |
| 10 UTF8; | 10 UTF8; |
| 11 | 11 |
| 12 import 'test_suite.dart' show | 12 import 'test_suite.dart' show |
| 13 TestSuite, | 13 TestSuite, |
| 14 TestUtils; | 14 TestUtils; |
| 15 | 15 |
| 16 import 'test_runner.dart' show | 16 import 'test_runner.dart' show |
| 17 Command, | 17 Command, |
| 18 CommandBuilder, | 18 CommandBuilder, |
| 19 CompilationCommandOutputImpl, | 19 CompilationCommandOutputImpl, |
| 20 TestCase; | 20 TestCase; |
| 21 | 21 |
| 22 import 'runtime_configuration.dart' show | 22 import 'runtime_configuration.dart' show |
| 23 RuntimeConfiguration; | 23 RuntimeConfiguration; |
| 24 | 24 |
| 25 import 'status_file_parser.dart' show | 25 import 'status_file_parser.dart' show |
| 26 Expectation, | 26 Expectation, |
| 27 TestExpectations; | 27 TestExpectations; |
| 28 | 28 |
| 29 import 'compiler_configuration.dart' show | 29 import 'compiler_configuration.dart' show |
| 30 CommandArtifact; | 30 CommandArtifact; |
| 31 | 31 |
| 32 const Map<String, String> URIS_TO_ANALYZE = const <String, String>{ | 32 const Map<String, String> URIS_TO_ANALYZE = const <String, String>{ |
| 33 "hub_main": "package:fletchc/src/hub/hub_main.dart", | 33 "hub_main": "package:dartino_compiler/src/hub/hub_main.dart", |
| 34 "fletch_test_suite": "tests/fletch_tests/fletch_test_suite.dart", | 34 "dartino_test_suite": "tests/dartino_tests/dartino_test_suite.dart", |
| 35 "test_dart": "tools/test.dart", | 35 "test_dart": "tools/test.dart", |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 class FletchWarningsRuntimeConfiguration extends RuntimeConfiguration { | 38 class DartinoWarningsRuntimeConfiguration extends RuntimeConfiguration { |
| 39 final String system; | 39 final String system; |
| 40 final String dartBinary; | 40 final String dartBinary; |
| 41 | 41 |
| 42 FletchWarningsRuntimeConfiguration(Map configuration) | 42 DartinoWarningsRuntimeConfiguration(Map configuration) |
| 43 : system = configuration['system'], | 43 : system = configuration['system'], |
| 44 dartBinary = '${TestUtils.buildDir(configuration)}' | 44 dartBinary = '${TestUtils.buildDir(configuration)}' |
| 45 '${io.Platform.pathSeparator}dart', | 45 '${io.Platform.pathSeparator}dart', |
| 46 super.subclass(); | 46 super.subclass(); |
| 47 | 47 |
| 48 List<Command> computeRuntimeCommands( | 48 List<Command> computeRuntimeCommands( |
| 49 TestSuite suite, | 49 TestSuite suite, |
| 50 CommandBuilder commandBuilder, | 50 CommandBuilder commandBuilder, |
| 51 CommandArtifact artifact, | 51 CommandArtifact artifact, |
| 52 String script, | 52 String script, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 63 '--library-root=third_party/dart/sdk/', | 63 '--library-root=third_party/dart/sdk/', |
| 64 '--analyze-only', | 64 '--analyze-only', |
| 65 '--show-package-warnings', | 65 '--show-package-warnings', |
| 66 '--categories=Server', | 66 '--categories=Server', |
| 67 '--allow-native-extensions']..addAll(arguments), | 67 '--allow-native-extensions']..addAll(arguments), |
| 68 null, | 68 null, |
| 69 flavor: 'dart2js')]; | 69 flavor: 'dart2js')]; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 class FletchWarningsSuite extends TestSuite { | 73 class DartinoWarningsSuite extends TestSuite { |
| 74 FletchWarningsSuite(Map configuration, testSuiteDir) | 74 DartinoWarningsSuite(Map configuration, testSuiteDir) |
| 75 : super(configuration, "warnings"); | 75 : super(configuration, "warnings"); |
| 76 | 76 |
| 77 void forEachTest( | 77 void forEachTest( |
| 78 void onTest(TestCase testCase), | 78 void onTest(TestCase testCase), |
| 79 Map testCache, | 79 Map testCache, |
| 80 [void onDone()]) { | 80 [void onDone()]) { |
| 81 this.doTest = onTest; | 81 this.doTest = onTest; |
| 82 if (configuration['runtime'] != 'fletch_warnings') { | 82 if (configuration['runtime'] != 'dartino_warnings') { |
| 83 onDone(); | 83 onDone(); |
| 84 return; | 84 return; |
| 85 } | 85 } |
| 86 | 86 |
| 87 RuntimeConfiguration runtimeConfiguration = | 87 RuntimeConfiguration runtimeConfiguration = |
| 88 new RuntimeConfiguration(configuration); | 88 new RuntimeConfiguration(configuration); |
| 89 | 89 |
| 90 // There are no status files for this. Please fix warnings. | 90 // There are no status files for this. Please fix warnings. |
| 91 TestExpectations expectations = new TestExpectations(); | 91 TestExpectations expectations = new TestExpectations(); |
| 92 | 92 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 107 | 107 |
| 108 onDone(); | 108 onDone(); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 /// Pattern that matches warnings (from dart2js) that contain a comment saying | 112 /// Pattern that matches warnings (from dart2js) that contain a comment saying |
| 113 /// "NO_LINT". | 113 /// "NO_LINT". |
| 114 final RegExp noLintFilter = | 114 final RegExp noLintFilter = |
| 115 new RegExp(r"[^\n]*\n[^\n]*\n[^\n]* // NO_LINT\n *\^+\n"); | 115 new RegExp(r"[^\n]*\n[^\n]*\n[^\n]* // NO_LINT\n *\^+\n"); |
| 116 | 116 |
| 117 class FletchWarningsOutputCommand extends CompilationCommandOutputImpl { | 117 class DartinoWarningsOutputCommand extends CompilationCommandOutputImpl { |
| 118 FletchWarningsOutputCommand( | 118 DartinoWarningsOutputCommand( |
| 119 Command command, int exitCode, bool timedOut, | 119 Command command, int exitCode, bool timedOut, |
| 120 List<int> stdout, List<int> stderr, | 120 List<int> stdout, List<int> stderr, |
| 121 Duration time, bool compilationSkipped) | 121 Duration time, bool compilationSkipped) |
| 122 : super( | 122 : super( |
| 123 command, exitCode, timedOut, stdout, stderr, time, | 123 command, exitCode, timedOut, stdout, stderr, time, |
| 124 compilationSkipped); | 124 compilationSkipped); |
| 125 | 125 |
| 126 Expectation result(TestCase testCase) { | 126 Expectation result(TestCase testCase) { |
| 127 Expectation result = super.result(testCase); | 127 Expectation result = super.result(testCase); |
| 128 if (result != Expectation.PASS) return result; | 128 if (result != Expectation.PASS) return result; |
| 129 | 129 |
| 130 var filteredStdout = | 130 var filteredStdout = |
| 131 UTF8.decode(stdout, allowMalformed: true).replaceAll(noLintFilter, ""); | 131 UTF8.decode(stdout, allowMalformed: true).replaceAll(noLintFilter, ""); |
| 132 if (filteredStdout.isNotEmpty) { | 132 if (filteredStdout.isNotEmpty) { |
| 133 return Expectation.STATIC_WARNING; | 133 return Expectation.STATIC_WARNING; |
| 134 } | 134 } |
| 135 | 135 |
| 136 return Expectation.PASS; | 136 return Expectation.PASS; |
| 137 } | 137 } |
| 138 } | 138 } |
| OLD | NEW |