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