| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 scheduled_process_test; | 5 library scheduled_process_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:pathos/path.dart' as path; | 10 import 'package:pathos/path.dart' as path; |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 }); | 358 }); |
| 359 } | 359 } |
| 360 | 360 |
| 361 ScheduledProcess startDartProcess(String script) { | 361 ScheduledProcess startDartProcess(String script) { |
| 362 var tempDir = schedule(() { | 362 var tempDir = schedule(() { |
| 363 return new Directory('').createTemp().then((dir) => dir.path); | 363 return new Directory('').createTemp().then((dir) => dir.path); |
| 364 }, 'create temp dir'); | 364 }, 'create temp dir'); |
| 365 | 365 |
| 366 var dartPath = schedule(() { | 366 var dartPath = schedule(() { |
| 367 return tempDir.then((dir) { | 367 return tempDir.then((dir) { |
| 368 var utilsPath = path.absolute(path.join( | 368 var utilsPath = path.absolute(path.join(Platform.script, 'utils.dart')); |
| 369 new Options().script, 'utils.dart')); | |
| 370 return new File(path.join(dir, 'test.dart')).writeAsString(''' | 369 return new File(path.join(dir, 'test.dart')).writeAsString(''' |
| 371 import 'dart:async'; | 370 import 'dart:async'; |
| 372 import 'dart:io'; | 371 import 'dart:io'; |
| 373 | 372 |
| 374 var stdinLines = stdin | 373 var stdinLines = stdin |
| 375 .transform(new StringDecoder()) | 374 .transform(new StringDecoder()) |
| 376 .transform(new LineTransformer()); | 375 .transform(new LineTransformer()); |
| 377 | 376 |
| 378 void main() { | 377 void main() { |
| 379 $script | 378 $script |
| 380 } | 379 } |
| 381 ''').then((file) => file.path); | 380 ''').then((file) => file.path); |
| 382 }); | 381 }); |
| 383 }, 'write script file'); | 382 }, 'write script file'); |
| 384 | 383 |
| 385 currentSchedule.onComplete.schedule(() { | 384 currentSchedule.onComplete.schedule(() { |
| 386 return tempDir.catchError((_) => null).then((dir) { | 385 return tempDir.catchError((_) => null).then((dir) { |
| 387 if (dir == null) return; | 386 if (dir == null) return; |
| 388 return new Directory(dir).delete(recursive: true); | 387 return new Directory(dir).delete(recursive: true); |
| 389 }); | 388 }); |
| 390 }, 'clean up temp dir'); | 389 }, 'clean up temp dir'); |
| 391 | 390 |
| 392 return new ScheduledProcess.start(dartExecutable, ['--checked', dartPath]); | 391 return new ScheduledProcess.start(dartExecutable, ['--checked', dartPath]); |
| 393 } | 392 } |
| OLD | NEW |