OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 "dart:async"; | 5 import "dart:async"; |
6 import "dart:convert"; | 6 import "dart:convert"; |
7 import "dart:io"; | 7 import "dart:io"; |
8 | 8 |
9 testAddressParse() async { | 9 testAddressParse() async { |
10 print(new InternetAddress("1.0.2.3").rawAddress); | 10 print(new InternetAddress("1.0.2.3").rawAddress); |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 390 |
391 void testProcessRunSync() { | 391 void testProcessRunSync() { |
392 String exe = Platform.resolvedExecutable; | 392 String exe = Platform.resolvedExecutable; |
393 print("Running $exe --version"); | 393 print("Running $exe --version"); |
394 var result = Process.runSync(exe, ["--version"]); | 394 var result = Process.runSync(exe, ["--version"]); |
395 print("$exe --version exited with code ${result.exitCode}"); | 395 print("$exe --version exited with code ${result.exitCode}"); |
396 print("$exe --version had stdout = '${result.stdout}'"); | 396 print("$exe --version had stdout = '${result.stdout}'"); |
397 print("$exe --version had stderr = '${result.stderr}'"); | 397 print("$exe --version had stderr = '${result.stderr}'"); |
398 } | 398 } |
399 | 399 |
| 400 Future testKill() async { |
| 401 String exe = Platform.resolvedExecutable; |
| 402 String script = Platform.script.path; |
| 403 print("Running $exe $script"); |
| 404 Process p = await Process.start(exe, [script, "infinite-loop"]); |
| 405 await new Future.delayed(const Duration(seconds: 1)); |
| 406 p.kill(); |
| 407 int code = await p.exitCode; |
| 408 print("$exe $script exited with code $code"); |
| 409 } |
| 410 |
400 Future testLs(String path) async { | 411 Future testLs(String path) async { |
401 Stream<FileSystemEntity> stream = (new Directory(path)).list(); | 412 Stream<FileSystemEntity> stream = (new Directory(path)).list(); |
402 await for (FileSystemEntity fse in stream) { | 413 await for (FileSystemEntity fse in stream) { |
403 print(fse.path); | 414 print(fse.path); |
404 } | 415 } |
405 } | 416 } |
406 | 417 |
407 void testPlatformEnvironment() { | 418 void testPlatformEnvironment() { |
408 Map<String, String> env = Platform.environment; | 419 Map<String, String> env = Platform.environment; |
409 for (String k in env.keys) { | 420 for (String k in env.keys) { |
(...skipping 14 matching lines...) Expand all Loading... |
424 List<int> resultData = await destFile.readAsBytes(); | 435 List<int> resultData = await destFile.readAsBytes(); |
425 assert(data.length == resultData.length); | 436 assert(data.length == resultData.length); |
426 for (int i = 0; i < data.length; i++) { | 437 for (int i = 0; i < data.length; i++) { |
427 assert(data[i] == resultData[i]); | 438 assert(data[i] == resultData[i]); |
428 } | 439 } |
429 await sourceFile.delete(); | 440 await sourceFile.delete(); |
430 await destFile.delete(); | 441 await destFile.delete(); |
431 await tmp.delete(); | 442 await tmp.delete(); |
432 } | 443 } |
433 | 444 |
434 main() async { | 445 main(List<String> args) async { |
| 446 if (args.length >= 1) { |
| 447 if (args[0] == "infinite-loop") { |
| 448 while (true); |
| 449 } |
| 450 } |
| 451 |
435 print("Hello, Fuchsia!"); | 452 print("Hello, Fuchsia!"); |
436 | 453 |
437 print("testAddressParse"); | 454 print("testAddressParse"); |
438 await testAddressParse(); | 455 await testAddressParse(); |
439 print("testAddressParse done"); | 456 print("testAddressParse done"); |
440 | 457 |
441 print("testSimpleBind"); | 458 print("testSimpleBind"); |
442 await testSimpleBind(); | 459 await testSimpleBind(); |
443 print("testSimpleBind done"); | 460 print("testSimpleBind done"); |
444 | 461 |
(...skipping 26 matching lines...) Expand all Loading... |
471 print("testPlatformEnvironment done"); | 488 print("testPlatformEnvironment done"); |
472 | 489 |
473 print("testProcess"); | 490 print("testProcess"); |
474 await testProcess(); | 491 await testProcess(); |
475 print("testProcess done"); | 492 print("testProcess done"); |
476 | 493 |
477 print("testProcessRunSync"); | 494 print("testProcessRunSync"); |
478 testProcessRunSync(); | 495 testProcessRunSync(); |
479 print("testProcessRunSync done"); | 496 print("testProcessRunSync done"); |
480 | 497 |
| 498 print("testKill"); |
| 499 await testKill(); |
| 500 print("testKill done"); |
| 501 |
481 print("testCopy"); | 502 print("testCopy"); |
482 await testCopy(); | 503 await testCopy(); |
483 print("testCopy done"); | 504 print("testCopy done"); |
484 | 505 |
485 print("Goodbyte, Fuchsia!"); | 506 print("Goodbyte, Fuchsia!"); |
486 } | 507 } |
OLD | NEW |