Commit 971ca4b8 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Check exit code for test subprocess (#7269)

parent 502592e5
This directory is used by ///flutter/travis/test.sh to verify that This directory is used by //flutter/dev/bots/test.sh to verify that
`flutter test` actually correctly fails when a test fails. `flutter test` actually correctly fails when a test fails.
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:io' as system;
import 'package:flutter_test/flutter_test.dart';
// this is a test to make sure our tests consider engine crashes to be failures
// see //flutter/dev/bots/test.sh
void main() {
test('test smoke test -- this test should fail', () async {
system.Process.killPid(system.pid, system.ProcessSignal.SIGSEGV);
});
}
\ No newline at end of file
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:io' as system;
// this is a test to make sure our tests consider engine crashes to be failures
// see //flutter/dev/bots/test.sh
void main() {
system.Process.killPid(system.pid, system.ProcessSignal.SIGSEGV);
}
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
// this is a test to make sure our tests actually catch failures // this is a test to make sure our tests actually catch failures
// see ///flutter/travis/test.sh // see //flutter/dev/bots/test.sh
void main() { void main() {
test('test smoke test -- this test SHOULD FAIL', () async { test('test smoke test -- this test SHOULD FAIL', () async {
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// this is a test to make sure our tests consider syntax errors to be failures
// see //flutter/dev/bots/test.sh
void main() {
fail(); // inspired by https://github.com/flutter/flutter/issues/2698
}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
// this is a test to make sure our tests actually catch failures // this is a test to make sure our tests actually catch failures
// see ///flutter/travis/test.sh // see //flutter/dev/bots/test.sh
void main() { void main() {
test('test smoke test -- this test should pass', () async { test('test smoke test -- this test should pass', () async {
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// this is a test to make sure our tests consider syntax errors to be failures
// see //flutter/dev/bots/test.sh
The challenge: demand satisfaction
If they apologize, no need for further action.
...@@ -22,6 +22,10 @@ flutter analyze --flutter-repo ...@@ -22,6 +22,10 @@ flutter analyze --flutter-repo
# verify that the tests actually return failure on failure and success on success # verify that the tests actually return failure on failure and success on success
(cd dev/automated_tests; ! flutter test test_smoke_test/fail_test.dart > /dev/null) (cd dev/automated_tests; ! flutter test test_smoke_test/fail_test.dart > /dev/null)
(cd dev/automated_tests; flutter test test_smoke_test/pass_test.dart > /dev/null) (cd dev/automated_tests; flutter test test_smoke_test/pass_test.dart > /dev/null)
(cd dev/automated_tests; ! flutter test test_smoke_test/crash1_test.dart > /dev/null)
(cd dev/automated_tests; ! flutter test test_smoke_test/crash2_test.dart > /dev/null)
(cd dev/automated_tests; ! flutter test test_smoke_test/syntax_error_test.broken_dart > /dev/null)
(cd dev/automated_tests; ! flutter test test_smoke_test/missing_import_test.broken_dart > /dev/null)
(cd packages/flutter_driver; ! flutter drive --use-existing-app -t test_driver/failure.dart >/dev/null 2>&1) (cd packages/flutter_driver; ! flutter drive --use-existing-app -t test_driver/failure.dart >/dev/null 2>&1)
COVERAGE_FLAG= COVERAGE_FLAG=
......
...@@ -6,7 +6,7 @@ import 'dart:async'; ...@@ -6,7 +6,7 @@ import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'package:test/src/executable.dart' as executable; // ignore: implementation_imports import 'package:test/src/executable.dart' as test; // ignore: implementation_imports
import '../base/common.dart'; import '../base/common.dart';
import '../base/logger.dart'; import '../base/logger.dart';
...@@ -77,9 +77,9 @@ class TestCommand extends FlutterCommand { ...@@ -77,9 +77,9 @@ class TestCommand extends FlutterCommand {
Directory.current = testDirectory; Directory.current = testDirectory;
} }
printTrace('running test package with arguments: $testArgs'); printTrace('running test package with arguments: $testArgs');
await executable.main(testArgs); await test.main(testArgs);
// test.main() sets dart:io's exitCode global.
printTrace('test package returned with exit code $exitCode'); printTrace('test package returned with exit code $exitCode');
return exitCode; return exitCode;
} finally { } finally {
Directory.current = currentDirectory; Directory.current = currentDirectory;
...@@ -164,10 +164,10 @@ class TestCommand extends FlutterCommand { ...@@ -164,10 +164,10 @@ class TestCommand extends FlutterCommand {
if (argResults['coverage']) if (argResults['coverage'])
testArgs.insert(0, '--concurrency=1'); testArgs.insert(0, '--concurrency=1');
loader.installHook(); final String shellPath = tools.getHostToolPath(HostTool.SkyShell) ?? Platform.environment['SKY_SHELL'];
loader.shellPath = tools.getHostToolPath(HostTool.SkyShell); if (!FileSystemEntity.isFileSync(shellPath))
if (!FileSystemEntity.isFileSync(loader.shellPath)) throwToolExit('Cannot find Flutter shell at $shellPath');
throwToolExit('Cannot find Flutter shell at ${loader.shellPath}'); loader.installHook(shellPath: shellPath);
Cache.releaseLockEarly(); Cache.releaseLockEarly();
......
...@@ -20,14 +20,14 @@ class CoverageCollector { ...@@ -20,14 +20,14 @@ class CoverageCollector {
void collectCoverage({ void collectCoverage({
String host, String host,
int port, int port,
Process processToKill Process processToKill,
}) { }) {
if (enabled) { if (enabled) {
assert(_jobs != null); assert(_jobs != null);
_jobs.add(_startJob( _jobs.add(_startJob(
host: host, host: host,
port: port, port: port,
processToKill: processToKill processToKill: processToKill,
)); ));
} else { } else {
processToKill.kill(); processToKill.kill();
...@@ -37,7 +37,7 @@ class CoverageCollector { ...@@ -37,7 +37,7 @@ class CoverageCollector {
Future<Null> _startJob({ Future<Null> _startJob({
String host, String host,
int port, int port,
Process processToKill Process processToKill,
}) async { }) async {
int pid = processToKill.pid; int pid = processToKill.pid;
printTrace('collecting coverage data from pid $pid on port $port'); printTrace('collecting coverage data from pid $pid on port $port');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment