| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer_cli.test.super_mixin; | 5 library analyzer_cli.test.super_mixin; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:analyzer_cli/src/ansi.dart' as ansi; |
| 9 import 'package:analyzer_cli/src/driver.dart' show Driver, errorSink, outSink; | 10 import 'package:analyzer_cli/src/driver.dart' show Driver, errorSink, outSink; |
| 10 import 'package:path/path.dart' as path; | 11 import 'package:path/path.dart' as path; |
| 11 import 'package:test/test.dart'; | 12 import 'package:test/test.dart'; |
| 12 | 13 |
| 13 import 'utils.dart'; | 14 import 'utils.dart'; |
| 14 | 15 |
| 15 /// End-to-end test for --supermixins. | 16 /// End-to-end test for --supermixins. |
| 16 /// | 17 /// |
| 17 /// Most super mixin tests are in Analyzer, but this verifies the option is | 18 /// Most super mixin tests are in Analyzer, but this verifies the option is |
| 18 /// working and producing extra errors as expected. | 19 /// working and producing extra errors as expected. |
| 19 /// | 20 /// |
| 20 /// Generally we don't want a lot of cases here as it requires spinning up a | 21 /// Generally we don't want a lot of cases here as it requires spinning up a |
| 21 /// full analysis context. | 22 /// full analysis context. |
| 22 void main() { | 23 void main() { |
| 23 group('--supermixins', () { | 24 group('--supermixins', () { |
| 24 StringSink savedOutSink, savedErrorSink; | 25 StringSink savedOutSink, savedErrorSink; |
| 25 int savedExitCode; | 26 int savedExitCode; |
| 27 |
| 26 setUp(() { | 28 setUp(() { |
| 29 ansi.runningTests = true; |
| 27 savedOutSink = outSink; | 30 savedOutSink = outSink; |
| 28 savedErrorSink = errorSink; | 31 savedErrorSink = errorSink; |
| 29 savedExitCode = exitCode; | 32 savedExitCode = exitCode; |
| 30 outSink = new StringBuffer(); | 33 outSink = new StringBuffer(); |
| 31 errorSink = new StringBuffer(); | 34 errorSink = new StringBuffer(); |
| 32 }); | 35 }); |
| 36 |
| 33 tearDown(() { | 37 tearDown(() { |
| 34 outSink = savedOutSink; | 38 outSink = savedOutSink; |
| 35 errorSink = savedErrorSink; | 39 errorSink = savedErrorSink; |
| 36 exitCode = savedExitCode; | 40 exitCode = savedExitCode; |
| 41 ansi.runningTests = false; |
| 37 }); | 42 }); |
| 38 | 43 |
| 39 test('produces errors when option absent', () async { | 44 test('produces errors when option absent', () async { |
| 40 var testPath = path.join(testDirectory, 'data/super_mixin_example.dart'); | 45 var testPath = path.join(testDirectory, 'data/super_mixin_example.dart'); |
| 41 await new Driver().start([testPath]); | 46 await new Driver().start([testPath]); |
| 42 | 47 |
| 43 expect(exitCode, 3); | 48 expect(exitCode, 3); |
| 44 var stdout = outSink.toString(); | 49 var stdout = outSink.toString(); |
| 45 expect( | 50 expect( |
| 46 stdout, | 51 stdout, |
| 47 contains( | 52 contains( |
| 48 "[error] The class 'C' can't be used as a mixin because it extends
a class other than Object")); | 53 "error • The class 'C' can't be used as a mixin because it extends
a class other than Object")); |
| 49 expect( | 54 expect( |
| 50 stdout, | 55 stdout, |
| 51 contains( | 56 contains( |
| 52 "[error] The class 'C' can't be used as a mixin because it referen
ces 'super'")); | 57 "error • The class 'C' can't be used as a mixin because it referen
ces 'super'")); |
| 53 expect(stdout, contains('2 errors found.')); | 58 expect(stdout, contains('2 errors found.')); |
| 54 expect(errorSink.toString(), ''); | 59 expect(errorSink.toString(), ''); |
| 55 }); | 60 }); |
| 56 | 61 |
| 57 test('produces no errors when option present', () async { | 62 test('produces no errors when option present', () async { |
| 58 var testPath = path.join(testDirectory, 'data/super_mixin_example.dart'); | 63 var testPath = path.join(testDirectory, 'data/super_mixin_example.dart'); |
| 59 await new Driver().start(['--supermixin', testPath]); | 64 await new Driver().start(['--supermixin', testPath]); |
| 60 | 65 |
| 61 expect(exitCode, 0); | 66 expect(exitCode, 0); |
| 62 var stdout = outSink.toString(); | 67 var stdout = outSink.toString(); |
| 63 expect(stdout, contains('No issues found')); | 68 expect(stdout, contains('No issues found')); |
| 64 }); | 69 }); |
| 65 }); | 70 }); |
| 66 } | 71 } |
| OLD | NEW |