Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: tools/testing/dart/test_runner.dart

Issue 145273024: Add support for copying coredumps to /tmp (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/testing/dart/test_progress.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /** 5 /**
6 * Classes and methods for executing tests. 6 * Classes and methods for executing tests.
7 * 7 *
8 * This module includes: 8 * This module includes:
9 * - Managing parallel execution of tests, including timeout checks. 9 * - Managing parallel execution of tests, including timeout checks.
10 * - Evaluating the output of each test as pass/fail/crash/timeout. 10 * - Evaluating the output of each test as pass/fail/crash/timeout.
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 737
738 CommandOutput get lastCommandOutput { 738 CommandOutput get lastCommandOutput {
739 if (commandOutputs.length == 0) { 739 if (commandOutputs.length == 0) {
740 throw new Exception("CommandOutputs is empty, maybe no command was run? (" 740 throw new Exception("CommandOutputs is empty, maybe no command was run? ("
741 "displayName: '$displayName', " 741 "displayName: '$displayName', "
742 "configurationString: '$configurationString')"); 742 "configurationString: '$configurationString')");
743 } 743 }
744 return commandOutputs[commands[commandOutputs.length - 1]]; 744 return commandOutputs[commands[commandOutputs.length - 1]];
745 } 745 }
746 746
747 Command get lastCommandExecuted {
748 if (commandOutputs.length == 0) {
749 throw new Exception("CommandOutputs is empty, maybe no command was run? ("
750 "displayName: '$displayName', "
751 "configurationString: '$configurationString')");
752 }
753 return commands[commandOutputs.length - 1];
754 }
755
747 int get timeout { 756 int get timeout {
748 if (expectedOutcomes.contains(Expectation.SLOW)) { 757 if (expectedOutcomes.contains(Expectation.SLOW)) {
749 return configuration['timeout'] * SLOW_TIMEOUT_MULTIPLIER; 758 return configuration['timeout'] * SLOW_TIMEOUT_MULTIPLIER;
750 } else { 759 } else {
751 return configuration['timeout']; 760 return configuration['timeout'];
752 } 761 }
753 } 762 }
754 763
755 String get configurationString { 764 String get configurationString {
756 final compiler = configuration['compiler']; 765 final compiler = configuration['compiler'];
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 class CommandOutputImpl extends UniqueObject implements CommandOutput { 873 class CommandOutputImpl extends UniqueObject implements CommandOutput {
865 Command command; 874 Command command;
866 int exitCode; 875 int exitCode;
867 876
868 bool timedOut; 877 bool timedOut;
869 List<int> stdout; 878 List<int> stdout;
870 List<int> stderr; 879 List<int> stderr;
871 Duration time; 880 Duration time;
872 List<String> diagnostics; 881 List<String> diagnostics;
873 bool compilationSkipped; 882 bool compilationSkipped;
883 int pid;
874 884
875 /** 885 /**
876 * A flag to indicate we have already printed a warning about ignoring the VM 886 * A flag to indicate we have already printed a warning about ignoring the VM
877 * crash, to limit the amount of output produced per test. 887 * crash, to limit the amount of output produced per test.
878 */ 888 */
879 bool alreadyPrintedWarning = false; 889 bool alreadyPrintedWarning = false;
880 890
881 // TODO(kustermann): Remove testCase from this class. 891 // TODO(kustermann): Remove testCase from this class.
882 CommandOutputImpl(Command this.command, 892 CommandOutputImpl(Command this.command,
883 int this.exitCode, 893 int this.exitCode,
884 bool this.timedOut, 894 bool this.timedOut,
885 List<int> this.stdout, 895 List<int> this.stdout,
886 List<int> this.stderr, 896 List<int> this.stderr,
887 Duration this.time, 897 Duration this.time,
888 bool this.compilationSkipped) { 898 bool this.compilationSkipped,
899 int this.pid) {
889 diagnostics = []; 900 diagnostics = [];
890 } 901 }
891 902
892 Expectation result(TestCase testCase) { 903 Expectation result(TestCase testCase) {
893 if (hasCrashed) return Expectation.CRASH; 904 if (hasCrashed) return Expectation.CRASH;
894 if (hasTimedOut) return Expectation.TIMEOUT; 905 if (hasTimedOut) return Expectation.TIMEOUT;
895 return hasFailed(testCase) ? Expectation.FAIL : Expectation.PASS; 906 return hasFailed(testCase) ? Expectation.FAIL : Expectation.PASS;
896 } 907 }
897 908
898 bool get hasCrashed { 909 bool get hasCrashed {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 stdout, 975 stdout,
965 stderr, 976 stderr,
966 time, 977 time,
967 compilationSkipped) : 978 compilationSkipped) :
968 super(command, 979 super(command,
969 exitCode, 980 exitCode,
970 timedOut, 981 timedOut,
971 stdout, 982 stdout,
972 stderr, 983 stderr,
973 time, 984 time,
974 compilationSkipped) { 985 compilationSkipped,
986 0) {
975 _failedBecauseOfMissingXDisplay = _didFailBecauseOfMissingXDisplay(); 987 _failedBecauseOfMissingXDisplay = _didFailBecauseOfMissingXDisplay();
976 if (_failedBecauseOfMissingXDisplay) { 988 if (_failedBecauseOfMissingXDisplay) {
977 DebugLogger.warning("Warning: Test failure because of missing XDisplay"); 989 DebugLogger.warning("Warning: Test failure because of missing XDisplay");
978 // If we get the X server error, or DRT crashes with a core dump, retry 990 // If we get the X server error, or DRT crashes with a core dump, retry
979 // the test. 991 // the test.
980 } 992 }
981 } 993 }
982 994
983 Expectation result(TestCase testCase) { 995 Expectation result(TestCase testCase) {
984 // Handle crashes and timeouts first 996 // Handle crashes and timeouts first
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 '${indent(result.browserOutput.stderr.toString(), 2)}\n' 1326 '${indent(result.browserOutput.stderr.toString(), 2)}\n'
1315 '\n'; 1327 '\n';
1316 return new BrowserControllerTestOutcome._internal( 1328 return new BrowserControllerTestOutcome._internal(
1317 command, result, outcome, encodeUtf8(stdout), encodeUtf8(stderr)); 1329 command, result, outcome, encodeUtf8(stdout), encodeUtf8(stderr));
1318 } 1330 }
1319 1331
1320 BrowserControllerTestOutcome._internal( 1332 BrowserControllerTestOutcome._internal(
1321 Command command, BrowserTestOutput result, this._rawOutcome, 1333 Command command, BrowserTestOutput result, this._rawOutcome,
1322 List<int> stdout, List<int> stderr) 1334 List<int> stdout, List<int> stderr)
1323 : super(command, 0, result.didTimeout, stdout, stderr, result.duration, 1335 : super(command, 0, result.didTimeout, stdout, stderr, result.duration,
1324 false) { 1336 false, 0) {
1325 _result = result; 1337 _result = result;
1326 } 1338 }
1327 1339
1328 Expectation result(TestCase testCase) { 1340 Expectation result(TestCase testCase) {
1329 // Handle timeouts first 1341 // Handle timeouts first
1330 if (_result.didTimeout) return Expectation.TIMEOUT; 1342 if (_result.didTimeout) return Expectation.TIMEOUT;
1331 1343
1332 // Multitests are handled specially 1344 // Multitests are handled specially
1333 if (testCase.info != null) { 1345 if (testCase.info != null) {
1334 if (testCase.info.hasRuntimeError) { 1346 if (testCase.info.hasRuntimeError) {
(...skipping 21 matching lines...) Expand all
1356 stdout, 1368 stdout,
1357 stderr, 1369 stderr,
1358 time, 1370 time,
1359 compilationSkipped) : 1371 compilationSkipped) :
1360 super(command, 1372 super(command,
1361 exitCode, 1373 exitCode,
1362 timedOut, 1374 timedOut,
1363 stdout, 1375 stdout,
1364 stderr, 1376 stderr,
1365 time, 1377 time,
1366 compilationSkipped); 1378 compilationSkipped,
1379 0);
1367 1380
1368 Expectation result(TestCase testCase) { 1381 Expectation result(TestCase testCase) {
1369 // TODO(kustermann): If we run the analyzer not in batch mode, make sure 1382 // TODO(kustermann): If we run the analyzer not in batch mode, make sure
1370 // that command.exitCodes matches 2 (errors), 1 (warnings), 0 (no warnings, 1383 // that command.exitCodes matches 2 (errors), 1 (warnings), 0 (no warnings,
1371 // no errors) 1384 // no errors)
1372 1385
1373 // Handle crashes and timeouts first 1386 // Handle crashes and timeouts first
1374 if (hasCrashed) return Expectation.CRASH; 1387 if (hasCrashed) return Expectation.CRASH;
1375 if (hasTimedOut) return Expectation.TIMEOUT; 1388 if (hasTimedOut) return Expectation.TIMEOUT;
1376 1389
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 } 1462 }
1450 } 1463 }
1451 } 1464 }
1452 1465
1453 class VmCommandOutputImpl extends CommandOutputImpl 1466 class VmCommandOutputImpl extends CommandOutputImpl
1454 with UnittestSuiteMessagesMixin { 1467 with UnittestSuiteMessagesMixin {
1455 static const DART_VM_EXITCODE_COMPILE_TIME_ERROR = 254; 1468 static const DART_VM_EXITCODE_COMPILE_TIME_ERROR = 254;
1456 static const DART_VM_EXITCODE_UNCAUGHT_EXCEPTION = 255; 1469 static const DART_VM_EXITCODE_UNCAUGHT_EXCEPTION = 255;
1457 1470
1458 VmCommandOutputImpl(Command command, int exitCode, bool timedOut, 1471 VmCommandOutputImpl(Command command, int exitCode, bool timedOut,
1459 List<int> stdout, List<int> stderr, Duration time) 1472 List<int> stdout, List<int> stderr, Duration time,
1460 : super(command, exitCode, timedOut, stdout, stderr, time, false); 1473 int pid)
1474 : super(command, exitCode, timedOut, stdout, stderr, time, false, pid);
1461 1475
1462 Expectation result(TestCase testCase) { 1476 Expectation result(TestCase testCase) {
1463 // Handle crashes and timeouts first 1477 // Handle crashes and timeouts first
1464 if (hasCrashed) return Expectation.CRASH; 1478 if (hasCrashed) return Expectation.CRASH;
1465 if (hasTimedOut) return Expectation.TIMEOUT; 1479 if (hasTimedOut) return Expectation.TIMEOUT;
1466 1480
1467 // Multitests are handled specially 1481 // Multitests are handled specially
1468 if (testCase.info != null) { 1482 if (testCase.info != null) {
1469 if (testCase.info.hasCompileError) { 1483 if (testCase.info.hasCompileError) {
1470 if (exitCode == DART_VM_EXITCODE_COMPILE_TIME_ERROR) { 1484 if (exitCode == DART_VM_EXITCODE_COMPILE_TIME_ERROR) {
(...skipping 29 matching lines...) Expand all
1500 } 1514 }
1501 } 1515 }
1502 1516
1503 class CompilationCommandOutputImpl extends CommandOutputImpl { 1517 class CompilationCommandOutputImpl extends CommandOutputImpl {
1504 static const DART2JS_EXITCODE_CRASH = 253; 1518 static const DART2JS_EXITCODE_CRASH = 253;
1505 1519
1506 CompilationCommandOutputImpl(Command command, int exitCode, bool timedOut, 1520 CompilationCommandOutputImpl(Command command, int exitCode, bool timedOut,
1507 List<int> stdout, List<int> stderr, Duration time, 1521 List<int> stdout, List<int> stderr, Duration time,
1508 bool compilationSkipped) 1522 bool compilationSkipped)
1509 : super(command, exitCode, timedOut, stdout, stderr, time, 1523 : super(command, exitCode, timedOut, stdout, stderr, time,
1510 compilationSkipped); 1524 compilationSkipped, 0);
1511 1525
1512 Expectation result(TestCase testCase) { 1526 Expectation result(TestCase testCase) {
1513 // Handle general crash/timeout detection. 1527 // Handle general crash/timeout detection.
1514 if (hasCrashed) return Expectation.CRASH; 1528 if (hasCrashed) return Expectation.CRASH;
1515 if (hasTimedOut) return Expectation.TIMEOUT; 1529 if (hasTimedOut) return Expectation.TIMEOUT;
1516 1530
1517 // Handle dart2js/dart2dart specific crash detection 1531 // Handle dart2js/dart2dart specific crash detection
1518 if (exitCode == DART2JS_EXITCODE_CRASH || 1532 if (exitCode == DART2JS_EXITCODE_CRASH ||
1519 exitCode == VmCommandOutputImpl.DART_VM_EXITCODE_COMPILE_TIME_ERROR || 1533 exitCode == VmCommandOutputImpl.DART_VM_EXITCODE_COMPILE_TIME_ERROR ||
1520 exitCode == VmCommandOutputImpl.DART_VM_EXITCODE_UNCAUGHT_EXCEPTION) { 1534 exitCode == VmCommandOutputImpl.DART_VM_EXITCODE_UNCAUGHT_EXCEPTION) {
(...skipping 23 matching lines...) Expand all
1544 Expectation outcome = 1558 Expectation outcome =
1545 exitCode == 0 ? Expectation.PASS : Expectation.COMPILETIME_ERROR; 1559 exitCode == 0 ? Expectation.PASS : Expectation.COMPILETIME_ERROR;
1546 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); 1560 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative);
1547 } 1561 }
1548 } 1562 }
1549 1563
1550 class JsCommandlineOutputImpl extends CommandOutputImpl 1564 class JsCommandlineOutputImpl extends CommandOutputImpl
1551 with UnittestSuiteMessagesMixin { 1565 with UnittestSuiteMessagesMixin {
1552 JsCommandlineOutputImpl(Command command, int exitCode, bool timedOut, 1566 JsCommandlineOutputImpl(Command command, int exitCode, bool timedOut,
1553 List<int> stdout, List<int> stderr, Duration time) 1567 List<int> stdout, List<int> stderr, Duration time)
1554 : super(command, exitCode, timedOut, stdout, stderr, time, false); 1568 : super(command, exitCode, timedOut, stdout, stderr, time, false, 0);
1555 1569
1556 Expectation result(TestCase testCase) { 1570 Expectation result(TestCase testCase) {
1557 // Handle crashes and timeouts first 1571 // Handle crashes and timeouts first
1558 if (hasCrashed) return Expectation.CRASH; 1572 if (hasCrashed) return Expectation.CRASH;
1559 if (hasTimedOut) return Expectation.TIMEOUT; 1573 if (hasTimedOut) return Expectation.TIMEOUT;
1560 1574
1561 if (testCase.info != null && testCase.info.hasRuntimeError) { 1575 if (testCase.info != null && testCase.info.hasRuntimeError) {
1562 if (exitCode != 0) return Expectation.PASS; 1576 if (exitCode != 0) return Expectation.PASS;
1563 return Expectation.MISSING_RUNTIME_ERROR; 1577 return Expectation.MISSING_RUNTIME_ERROR;
1564 } 1578 }
1565 1579
1566 var outcome = exitCode == 0 ? Expectation.PASS : Expectation.RUNTIME_ERROR; 1580 var outcome = exitCode == 0 ? Expectation.PASS : Expectation.RUNTIME_ERROR;
1567 outcome = _negateOutcomeIfIncompleteAsyncTest(outcome, decodeUtf8(stdout)); 1581 outcome = _negateOutcomeIfIncompleteAsyncTest(outcome, decodeUtf8(stdout));
1568 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); 1582 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative);
1569 } 1583 }
1570 } 1584 }
1571 1585
1572 class PubCommandOutputImpl extends CommandOutputImpl { 1586 class PubCommandOutputImpl extends CommandOutputImpl {
1573 PubCommandOutputImpl(PubCommand command, int exitCode, bool timedOut, 1587 PubCommandOutputImpl(PubCommand command, int exitCode, bool timedOut,
1574 List<int> stdout, List<int> stderr, Duration time) 1588 List<int> stdout, List<int> stderr, Duration time)
1575 : super(command, exitCode, timedOut, stdout, stderr, time, false); 1589 : super(command, exitCode, timedOut, stdout, stderr, time, false, 0);
1576 1590
1577 Expectation result(TestCase testCase) { 1591 Expectation result(TestCase testCase) {
1578 // Handle crashes and timeouts first 1592 // Handle crashes and timeouts first
1579 if (hasCrashed) return Expectation.CRASH; 1593 if (hasCrashed) return Expectation.CRASH;
1580 if (hasTimedOut) return Expectation.TIMEOUT; 1594 if (hasTimedOut) return Expectation.TIMEOUT;
1581 1595
1582 if (exitCode == 0) { 1596 if (exitCode == 0) {
1583 return Expectation.PASS; 1597 return Expectation.PASS;
1584 } else if ((command as PubCommand).command == 'get') { 1598 } else if ((command as PubCommand).command == 'get') {
1585 return Expectation.PUB_GET_ERROR; 1599 return Expectation.PUB_GET_ERROR;
1586 } else { 1600 } else {
1587 return Expectation.FAIL; 1601 return Expectation.FAIL;
1588 } 1602 }
1589 } 1603 }
1590 } 1604 }
1591 1605
1592 class ScriptCommandOutputImpl extends CommandOutputImpl { 1606 class ScriptCommandOutputImpl extends CommandOutputImpl {
1593 final Expectation _result; 1607 final Expectation _result;
1594 1608
1595 ScriptCommandOutputImpl(ScriptCommand command, this._result, 1609 ScriptCommandOutputImpl(ScriptCommand command, this._result,
1596 String scriptExecutionInformation, Duration time) 1610 String scriptExecutionInformation, Duration time)
1597 : super(command, 0, false, [], [], time, false) { 1611 : super(command, 0, false, [], [], time, false, 0) {
1598 var lines = scriptExecutionInformation.split("\n"); 1612 var lines = scriptExecutionInformation.split("\n");
1599 diagnostics.addAll(lines); 1613 diagnostics.addAll(lines);
1600 } 1614 }
1601 1615
1602 Expectation result(TestCase testCase) => _result; 1616 Expectation result(TestCase testCase) => _result;
1603 1617
1604 bool get canRunDependendCommands => _result == Expectation.PASS; 1618 bool get canRunDependendCommands => _result == Expectation.PASS;
1605 1619
1606 bool get successful => _result == Expectation.PASS; 1620 bool get successful => _result == Expectation.PASS;
1607 1621
1608 } 1622 }
1609 1623
1610 CommandOutput createCommandOutput(Command command, 1624 CommandOutput createCommandOutput(Command command,
1611 int exitCode, 1625 int exitCode,
1612 bool timedOut, 1626 bool timedOut,
1613 List<int> stdout, 1627 List<int> stdout,
1614 List<int> stderr, 1628 List<int> stderr,
1615 Duration time, 1629 Duration time,
1616 bool compilationSkipped) { 1630 bool compilationSkipped,
1631 [int pid = 0]) {
1617 if (command is ContentShellCommand) { 1632 if (command is ContentShellCommand) {
1618 return new BrowserCommandOutputImpl( 1633 return new BrowserCommandOutputImpl(
1619 command, exitCode, timedOut, stdout, stderr, 1634 command, exitCode, timedOut, stdout, stderr,
1620 time, compilationSkipped); 1635 time, compilationSkipped);
1621 } else if (command is BrowserTestCommand) { 1636 } else if (command is BrowserTestCommand) {
1622 return new HTMLBrowserCommandOutputImpl( 1637 return new HTMLBrowserCommandOutputImpl(
1623 command, exitCode, timedOut, stdout, stderr, 1638 command, exitCode, timedOut, stdout, stderr,
1624 time, compilationSkipped); 1639 time, compilationSkipped);
1625 } else if (command is AnalysisCommand) { 1640 } else if (command is AnalysisCommand) {
1626 return new AnalysisCommandOutputImpl( 1641 return new AnalysisCommandOutputImpl(
1627 command, exitCode, timedOut, stdout, stderr, 1642 command, exitCode, timedOut, stdout, stderr,
1628 time, compilationSkipped); 1643 time, compilationSkipped);
1629 } else if (command is VmCommand) { 1644 } else if (command is VmCommand) {
1630 return new VmCommandOutputImpl( 1645 return new VmCommandOutputImpl(
1631 command, exitCode, timedOut, stdout, stderr, time); 1646 command, exitCode, timedOut, stdout, stderr, time, pid);
1632 } else if (command is CompilationCommand) { 1647 } else if (command is CompilationCommand) {
1633 return new CompilationCommandOutputImpl( 1648 return new CompilationCommandOutputImpl(
1634 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); 1649 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped);
1635 } else if (command is JSCommandlineCommand) { 1650 } else if (command is JSCommandlineCommand) {
1636 return new JsCommandlineOutputImpl( 1651 return new JsCommandlineOutputImpl(
1637 command, exitCode, timedOut, stdout, stderr, time); 1652 command, exitCode, timedOut, stdout, stderr, time);
1638 } else if (command is PubCommand) { 1653 } else if (command is PubCommand) {
1639 return new PubCommandOutputImpl( 1654 return new PubCommandOutputImpl(
1640 command, exitCode, timedOut, stdout, stderr, time); 1655 command, exitCode, timedOut, stdout, stderr, time);
1641 } 1656 }
1642 1657
1643 return new CommandOutputImpl( 1658 return new CommandOutputImpl(
1644 command, exitCode, timedOut, stdout, stderr, 1659 command, exitCode, timedOut, stdout, stderr,
1645 time, compilationSkipped); 1660 time, compilationSkipped, pid);
1646 } 1661 }
1647 1662
1648 1663
1649 /** 1664 /**
1650 * A RunningProcess actually runs a test, getting the command lines from 1665 * A RunningProcess actually runs a test, getting the command lines from
1651 * its [TestCase], starting the test process (and first, a compilation 1666 * its [TestCase], starting the test process (and first, a compilation
1652 * process if the TestCase is a [BrowserTestCase]), creating a timeout 1667 * process if the TestCase is a [BrowserTestCase]), creating a timeout
1653 * timer, and recording the results in a new [CommandOutput] object, which it 1668 * timer, and recording the results in a new [CommandOutput] object, which it
1654 * attaches to the TestCase. The lifetime of the RunningProcess is limited 1669 * attaches to the TestCase. The lifetime of the RunningProcess is limited
1655 * to the time it takes to start the process, run the process, and record 1670 * to the time it takes to start the process, run the process, and record
1656 * the result; there are no pointers to it, so it should be available to 1671 * the result; there are no pointers to it, so it should be available to
1657 * be garbage collected as soon as it is done. 1672 * be garbage collected as soon as it is done.
1658 */ 1673 */
1659 class RunningProcess { 1674 class RunningProcess {
1660 ProcessCommand command; 1675 ProcessCommand command;
1661 int timeout; 1676 int timeout;
1662 bool timedOut = false; 1677 bool timedOut = false;
1663 DateTime startTime; 1678 DateTime startTime;
1664 Timer timeoutTimer; 1679 Timer timeoutTimer;
1680 int pid;
1665 List<int> stdout = <int>[]; 1681 List<int> stdout = <int>[];
1666 List<int> stderr = <int>[]; 1682 List<int> stderr = <int>[];
1667 bool compilationSkipped = false; 1683 bool compilationSkipped = false;
1668 Completer<CommandOutput> completer; 1684 Completer<CommandOutput> completer;
1669 1685
1670 RunningProcess(this.command, this.timeout); 1686 RunningProcess(this.command, this.timeout);
1671 1687
1672 Future<CommandOutput> run() { 1688 Future<CommandOutput> run() {
1673 completer = new Completer<CommandOutput>(); 1689 completer = new Completer<CommandOutput>();
1674 startTime = new DateTime.now(); 1690 startTime = new DateTime.now();
(...skipping 17 matching lines...) Expand all
1692 StreamSubscription stdoutSubscription = 1708 StreamSubscription stdoutSubscription =
1693 _drainStream(process.stdout, stdout); 1709 _drainStream(process.stdout, stdout);
1694 StreamSubscription stderrSubscription = 1710 StreamSubscription stderrSubscription =
1695 _drainStream(process.stderr, stderr); 1711 _drainStream(process.stderr, stderr);
1696 1712
1697 var stdoutCompleter = new Completer(); 1713 var stdoutCompleter = new Completer();
1698 var stderrCompleter = new Completer(); 1714 var stderrCompleter = new Completer();
1699 1715
1700 bool stdoutDone = false; 1716 bool stdoutDone = false;
1701 bool stderrDone = false; 1717 bool stderrDone = false;
1718 pid = process.pid;
1702 1719
1703 // This timer is used to close stdio to the subprocess once we got 1720 // This timer is used to close stdio to the subprocess once we got
1704 // the exitCode. Sometimes descendants of the subprocess keep stdio 1721 // the exitCode. Sometimes descendants of the subprocess keep stdio
1705 // handles alive even though the direct subprocess is dead. 1722 // handles alive even though the direct subprocess is dead.
1706 Timer watchdogTimer; 1723 Timer watchdogTimer;
1707 1724
1708 closeStdout([_]) { 1725 closeStdout([_]) {
1709 if (!stdoutDone) { 1726 if (!stdoutDone) {
1710 stdoutCompleter.complete(); 1727 stdoutCompleter.complete();
1711 stdoutDone = true; 1728 stdoutDone = true;
1712
1713 if (stderrDone && watchdogTimer != null) { 1729 if (stderrDone && watchdogTimer != null) {
1714 watchdogTimer.cancel(); 1730 watchdogTimer.cancel();
1715 } 1731 }
1716 } 1732 }
1717 } 1733 }
1718 closeStderr([_]) { 1734 closeStderr([_]) {
1719 if (!stderrDone) { 1735 if (!stderrDone) {
1720 stderrCompleter.complete(); 1736 stderrCompleter.complete();
1721 stderrDone = true; 1737 stderrDone = true;
1722 1738
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 } 1798 }
1783 1799
1784 CommandOutput _createCommandOutput(ProcessCommand command, int exitCode) { 1800 CommandOutput _createCommandOutput(ProcessCommand command, int exitCode) {
1785 var commandOutput = createCommandOutput( 1801 var commandOutput = createCommandOutput(
1786 command, 1802 command,
1787 exitCode, 1803 exitCode,
1788 timedOut, 1804 timedOut,
1789 stdout, 1805 stdout,
1790 stderr, 1806 stderr,
1791 new DateTime.now().difference(startTime), 1807 new DateTime.now().difference(startTime),
1792 compilationSkipped); 1808 compilationSkipped,
1809 pid);
1793 return commandOutput; 1810 return commandOutput;
1794 } 1811 }
1795 1812
1796 StreamSubscription _drainStream(Stream<List<int>> source, 1813 StreamSubscription _drainStream(Stream<List<int>> source,
1797 List<int> destination) { 1814 List<int> destination) {
1798 return source.listen(destination.addAll); 1815 return source.listen(destination.addAll);
1799 } 1816 }
1800 1817
1801 Map<String, String> _createProcessEnvironment() { 1818 Map<String, String> _createProcessEnvironment() {
1802 var environment = new Map.from(io.Platform.environment); 1819 var environment = new Map.from(io.Platform.environment);
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
2838 } 2855 }
2839 } 2856 }
2840 2857
2841 void eventAllTestsDone() { 2858 void eventAllTestsDone() {
2842 for (var listener in _eventListener) { 2859 for (var listener in _eventListener) {
2843 listener.allDone(); 2860 listener.allDone();
2844 } 2861 }
2845 _allDone(); 2862 _allDone();
2846 } 2863 }
2847 } 2864 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_progress.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698