| 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 linter.test.integration; | 5 library linter.test.integration; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:linter/src/config.dart'; | 10 import 'package:linter/src/config.dart'; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 exitCode = 0; | 185 exitCode = 0; |
| 186 outSink = collectingOut; | 186 outSink = collectingOut; |
| 187 }); | 187 }); |
| 188 tearDown(() { | 188 tearDown(() { |
| 189 collectingOut.buffer.clear(); | 189 collectingOut.buffer.clear(); |
| 190 outSink = currentOut; | 190 outSink = currentOut; |
| 191 exitCode = 0; | 191 exitCode = 0; |
| 192 }); | 192 }); |
| 193 | 193 |
| 194 test('close sinks', () { | 194 test('close sinks', () { |
| 195 dartlint.main([ | 195 dartlint.main(['test/_data/close_sinks', '--rules=close_sinks']); |
| 196 'test/_data/close_sinks', | |
| 197 '--rules=close_sinks' | |
| 198 ]); | |
| 199 expect(exitCode, 1); | 196 expect(exitCode, 1); |
| 200 expect( | 197 expect( |
| 201 collectingOut.trim(), | 198 collectingOut.trim(), |
| 202 stringContainsInOrder( | 199 stringContainsInOrder([ |
| 203 [ | 200 'IOSink _sinkA; // LINT', |
| 204 'IOSink _sinkA; // LINT', | 201 'IOSink _sinkF; // LINT', |
| 205 'IOSink _sinkF; // LINT', | 202 '1 file analyzed, 2 issues found, in' |
| 206 '1 file analyzed, 2 issues found, in' | 203 ])); |
| 207 ])); | |
| 208 }); | 204 }); |
| 209 }); | 205 }); |
| 210 | 206 |
| 211 group('cancel_subscriptions', () { | 207 group('cancel_subscriptions', () { |
| 212 IOSink currentOut = outSink; | 208 IOSink currentOut = outSink; |
| 213 CollectingSink collectingOut = new CollectingSink(); | 209 CollectingSink collectingOut = new CollectingSink(); |
| 214 setUp(() { | 210 setUp(() { |
| 215 exitCode = 0; | 211 exitCode = 0; |
| 216 outSink = collectingOut; | 212 outSink = collectingOut; |
| 217 }); | 213 }); |
| 218 tearDown(() { | 214 tearDown(() { |
| 219 collectingOut.buffer.clear(); | 215 collectingOut.buffer.clear(); |
| 220 outSink = currentOut; | 216 outSink = currentOut; |
| 221 exitCode = 0; | 217 exitCode = 0; |
| 222 }); | 218 }); |
| 223 | 219 |
| 224 test('cancel subscriptions', () { | 220 test('cancel subscriptions', () { |
| 225 dartlint.main([ | 221 dartlint.main([ |
| 226 'test/_data/cancel_subscriptions', | 222 'test/_data/cancel_subscriptions', |
| 227 '--rules=cancel_subscriptions' | 223 '--rules=cancel_subscriptions' |
| 228 ]); | 224 ]); |
| 229 expect(exitCode, 1); | 225 expect(exitCode, 1); |
| 230 expect( | 226 expect( |
| 231 collectingOut.trim(), | 227 collectingOut.trim(), |
| 232 stringContainsInOrder( | 228 stringContainsInOrder([ |
| 233 [ | 229 'StreamSubscription _subscriptionA; // LINT', |
| 234 'StreamSubscription _subscriptionA; // LINT', | 230 'StreamSubscription _subscriptionF; // LINT', |
| 235 'StreamSubscription _subscriptionF; // LINT', | 231 '1 file analyzed, 2 issues found, in' |
| 236 '1 file analyzed, 2 issues found, in' | 232 ])); |
| 237 ])); | |
| 238 }); | 233 }); |
| 239 }); | 234 }); |
| 240 | 235 |
| 241 group('only_throw_error', () { | 236 group('only_throw_errors', () { |
| 242 IOSink currentOut = outSink; | 237 IOSink currentOut = outSink; |
| 243 CollectingSink collectingOut = new CollectingSink(); | 238 CollectingSink collectingOut = new CollectingSink(); |
| 244 setUp(() { | 239 setUp(() { |
| 245 exitCode = 0; | 240 exitCode = 0; |
| 246 outSink = collectingOut; | 241 outSink = collectingOut; |
| 247 }); | 242 }); |
| 248 tearDown(() { | 243 tearDown(() { |
| 249 collectingOut.buffer.clear(); | 244 collectingOut.buffer.clear(); |
| 250 outSink = currentOut; | 245 outSink = currentOut; |
| 251 exitCode = 0; | 246 exitCode = 0; |
| 252 }); | 247 }); |
| 253 | 248 |
| 254 test('only throw error', () { | 249 test('only throw errors', () { |
| 255 dartlint.main([ | 250 dartlint.main( |
| 256 'test/_data/only_throw_error', | 251 ['test/_data/only_throw_errors', '--rules=only_throw_errors']); |
| 257 '--rules=only_throw_error' | |
| 258 ]); | |
| 259 expect(exitCode, 1); | 252 expect(exitCode, 1); |
| 260 expect( | 253 expect( |
| 261 collectingOut.trim(), | 254 collectingOut.trim(), |
| 262 stringContainsInOrder( | 255 stringContainsInOrder([ |
| 263 [ | 256 "throw 'hello world!'; // LINT", |
| 264 "throw 'hello world!'; // LINT", | 257 'throw null; // LINT', |
| 265 'throw null; // LINT', | 258 'throw 7; // LINT', |
| 266 'throw 7; // LINT', | 259 'throw new Object(); // LINT', |
| 267 'throw new Object(); // LINT', | 260 'throw returnString(); // LINT', |
| 268 'throw returnString(); // LINT', | 261 '1 file analyzed, 5 issues found, in' |
| 269 '1 file analyzed, 5 issues found, in' | 262 ])); |
| 270 ])); | |
| 271 }); | 263 }); |
| 272 }); | 264 }); |
| 273 | 265 |
| 274 group('examples', () { | 266 group('examples', () { |
| 275 test('lintconfig.yaml', () { | 267 test('lintconfig.yaml', () { |
| 276 var src = readFile('example/lintconfig.yaml'); | 268 var src = readFile('example/lintconfig.yaml'); |
| 277 var config = new LintConfig.parse(src); | 269 var config = new LintConfig.parse(src); |
| 278 expect(config.fileIncludes, unorderedEquals(['foo/**'])); | 270 expect(config.fileIncludes, unorderedEquals(['foo/**'])); |
| 279 expect( | 271 expect( |
| 280 config.fileExcludes, unorderedEquals(['**/_data.dart', 'test/**'])); | 272 config.fileExcludes, unorderedEquals(['**/_data.dart', 'test/**'])); |
| 281 expect(config.ruleConfigs, hasLength(1)); | 273 expect(config.ruleConfigs, hasLength(1)); |
| 282 var ruleConfig = config.ruleConfigs[0]; | 274 var ruleConfig = config.ruleConfigs[0]; |
| 283 expect(ruleConfig.group, 'style_guide'); | 275 expect(ruleConfig.group, 'style_guide'); |
| 284 expect(ruleConfig.name, 'unnecessary_getters'); | 276 expect(ruleConfig.name, 'unnecessary_getters'); |
| 285 expect(ruleConfig.args, {'enabled': false}); | 277 expect(ruleConfig.args, {'enabled': false}); |
| 286 }); | 278 }); |
| 287 }); | 279 }); |
| 288 }); | 280 }); |
| 289 } | 281 } |
| 290 | 282 |
| 291 class MockProcessResult extends Mock implements ProcessResult {} | 283 class MockProcessResult extends Mock implements ProcessResult {} |
| OLD | NEW |