| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import "package:expect/expect.dart"; |
| 5 import 'dart:io'; | 6 import 'dart:io'; |
| 6 | 7 |
| 7 main() { | 8 main() { |
| 8 Directory temp = new Directory('').createTempSync(); | 9 Directory temp = new Directory('').createTempSync(); |
| 9 File script = new File('${temp.path}/script.dart'); | 10 File script = new File('${temp.path}/script.dart'); |
| 10 script.writeAsStringSync(""" | 11 script.writeAsStringSync(""" |
| 11 import 'dart:io'; | 12 import 'dart:io'; |
| 12 | 13 |
| 14 class Expect { |
| 15 static void isTrue(var x) { |
| 16 if (!identical(x, true)) { |
| 17 throw new Error("Not identical"); |
| 18 } |
| 19 } |
| 20 } |
| 21 |
| 13 main() { | 22 main() { |
| 14 Directory d = new Directory('a'); | 23 Directory d = new Directory('a'); |
| 15 d.create(recursive: true).then((_) { | 24 d.create(recursive: true).then((_) { |
| 16 d.exists().then((result) { | 25 d.exists().then((result) { |
| 17 Expect.isTrue(result); | 26 Expect.isTrue(result); |
| 18 d = new Directory('b/c/d'); | 27 d = new Directory('b/c/d'); |
| 19 d.create(recursive: true).then((_) { | 28 d.create(recursive: true).then((_) { |
| 20 d.exists().then((result) { | 29 d.exists().then((result) { |
| 21 Expect.isTrue(result); | 30 Expect.isTrue(result); |
| 22 }); | 31 }); |
| 23 }); | 32 }); |
| 24 }); | 33 }); |
| 25 }); | 34 }); |
| 26 } | 35 } |
| 27 """); | 36 """); |
| 28 ProcessOptions options = new ProcessOptions(); | 37 ProcessOptions options = new ProcessOptions(); |
| 29 options.workingDirectory = temp.path; | 38 options.workingDirectory = temp.path; |
| 30 String executable = new File(new Options().executable).fullPathSync(); | 39 String executable = new File(new Options().executable).fullPathSync(); |
| 31 Process.run(executable, ['script.dart'], options).then((result) { | 40 Process.run(executable, ['script.dart'], options).then((result) { |
| 32 temp.deleteSync(recursive: true); | 41 temp.deleteSync(recursive: true); |
| 33 Expect.equals(0, result.exitCode); | 42 Expect.equals(0, result.exitCode); |
| 34 }); | 43 }); |
| 35 } | 44 } |
| OLD | NEW |