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

Unified Diff: pkg/scheduled_test/test/scheduled_process_test.dart

Issue 812253002: Delete a bunch of packages that are now on GitHub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Un-delete http Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: pkg/scheduled_test/test/scheduled_process_test.dart
diff --git a/pkg/scheduled_test/test/scheduled_process_test.dart b/pkg/scheduled_test/test/scheduled_process_test.dart
deleted file mode 100644
index 2cdb9ae433612c009f91c7f843773272ab4db46a..0000000000000000000000000000000000000000
--- a/pkg/scheduled_test/test/scheduled_process_test.dart
+++ /dev/null
@@ -1,256 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library scheduled_process_test;
-
-import 'dart:async';
-import 'dart:io';
-
-import 'package:path/path.dart' as path;
-import 'package:scheduled_test/scheduled_process.dart';
-import 'package:scheduled_test/scheduled_stream.dart';
-import 'package:scheduled_test/scheduled_test.dart';
-
-import 'package:metatest/metatest.dart';
-import 'utils.dart';
-
-void main() => initTests(_test);
-
-void _test(message) {
- initMetatest(message);
-
- setUpTimeout();
-
- expectTestsPass("a process must have kill() or shouldExit() called", () {
- var errors;
- test('test 1', () {
- currentSchedule.onException.schedule(() {
- errors = currentSchedule.errors;
- });
-
- startDartProcess('print("hello!");');
- });
-
- test('test 2', () {
- expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
- expect(errors.length, equals(1));
- expect(errors.first.error, isStateError);
- expect(errors.first.error.message, matches(r"^Scheduled process "
- r"'[^']+[\\/]dart(\.exe)?' must have shouldExit\(\) or kill\(\) "
- r"called before the test is run\.$"));
- });
- }, passing: ['test 2']);
-
- expectTestsPass("a process exits with the expected exit code", () {
- test('exit code 0', () {
- var process = startDartProcess('exitCode = 0;');
- process.shouldExit(0);
- });
-
- test('exit code 42', () {
- var process = startDartProcess('exitCode = 42;');
- process.shouldExit(42);
- });
- });
-
- expectTestsPass("a process exiting with an unexpected exit code should cause "
- "an error", () {
- var errors;
- test('test 1', () {
- currentSchedule.onException.schedule(() {
- errors = currentSchedule.errors;
- });
-
- var process = startDartProcess('exitCode = 1;');
- process.shouldExit(0);
- });
-
- test('test 2', () {
- expect(errors.single, new isInstanceOf<ScheduleError>());
- });
- }, passing: ['test 2']);
-
- expectTestsPass("a killed process doesn't care about its exit code", () {
- test('exit code 0', () {
- var process = startDartProcess('exitCode = 0;');
- process.kill();
- });
-
- test('exit code 1', () {
- var process = startDartProcess('exitCode = 1;');
- process.kill();
- });
- });
-
- expectTestsPass("a killed process stops running", () {
- test('test', () {
- var process = startDartProcess('while (true);');
- process.kill();
- });
- });
-
- expectTestsPass("kill can't be called twice", () {
- test('test', () {
- var process = startDartProcess('');
- process.kill();
- expect(process.kill, throwsA(isStateError));
- });
- });
-
- expectTestsPass("kill can't be called after shouldExit", () {
- test('test', () {
- var process = startDartProcess('');
- process.shouldExit(0);
- expect(process.kill, throwsA(isStateError));
- });
- });
-
- expectTestsPass("shouldExit can't be called twice", () {
- test('test', () {
- var process = startDartProcess('');
- process.shouldExit(0);
- expect(() => process.shouldExit(0), throwsA(isStateError));
- });
- });
-
- expectTestsPass("shouldExit can't be called after kill", () {
- test('test', () {
- var process = startDartProcess('');
- process.kill();
- expect(() => process.shouldExit(0), throwsA(isStateError));
- });
- });
-
- expectTestsPass("a process that ends while waiting for stdout shouldn't "
- "block the test", () {
- var errors;
- test('test 1', () {
- currentSchedule.onException.schedule(() {
- errors = currentSchedule.errors;
- });
-
- var process = startDartProcess('');
- process.stdout.expect('hello');
- process.stdout.expect('world');
- process.shouldExit(0);
- });
-
- test('test 2', () {
- expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
- expect(errors.length, anyOf(1, 2));
- expect(errors[0].error, new isInstanceOf<TestFailure>());
- expect(errors[0].error.message, equals(
- "Expected: 'hello'\n"
- " Emitted: \n"
- " Which: unexpected end of stream"));
-
- // Whether or not this error appears depends on how quickly the "no
- // elements" error is handled.
- if (errors.length == 2) {
- expect(errors[1].error.toString(), matches(r"^Process "
- r"'[^']+[\\/]dart(\.exe)? [^']+' ended earlier than scheduled with "
- r"exit code 0\."));
- }
- });
- }, passing: ['test 2']);
-
- expectTestsPass("a process that ends during the task immediately before it's "
- "scheduled to end shouldn't cause an error", () {
- test('test', () {
- var process = startDartProcess('stdin.toList();');
- process.closeStdin();
- // Unfortunately, sleeping for a second seems like the best way of
- // guaranteeing that the process ends during this task.
- schedule(() => new Future.delayed(new Duration(seconds: 1)));
- process.shouldExit(0);
- });
- });
-
- expectTestsPass("stdout exposes the standard output from the process", () {
- test('test', () {
- var process = startDartProcess(r'print("hello\n\nworld"); print("hi");');
- process.stdout.expect('hello');
- process.stdout.expect('');
- process.stdout.expect('world');
- process.stdout.expect('hi');
- process.stdout.expect(isDone);
- process.shouldExit(0);
- });
- });
-
- expectTestsPass("stderr exposes the stderr from the process", () {
- test('test', () {
- var process = startDartProcess(r'''
- stderr.write("hello\n\nworld\n");
- stderr.write("hi");
- ''');
- process.stderr.expect('hello');
- process.stderr.expect('');
- process.stderr.expect('world');
- process.stderr.expect('hi');
- process.stderr.expect(isDone);
- process.shouldExit(0);
- });
- });
-
- expectTestsPass("writeLine schedules a line to be written to the process",
- () {
- test('test', () {
- var process = startDartProcess(r'''
- stdinLines.listen((line) => print("> $line"));
- ''');
- process.writeLine("hello");
- process.stdout.expect("> hello");
- process.writeLine("world");
- process.stdout.expect("> world");
- process.kill();
- });
- });
-
- expectTestsPass("closeStdin closes the process's stdin stream", () {
- test('test', () {
- var process = startDartProcess(r'''
- stdin.listen((line) => print("> $line"),
- onDone: () => print("stdin closed"));
- ''');
- process.closeStdin();
- process.shouldExit(0);
- process.stdout.expect('stdin closed');
- });
- });
-}
-
-ScheduledProcess startDartProcess(String script) {
- var tempDir = schedule(() => Directory.systemTemp
- .createTemp('scheduled_process_test_')
- .then((dir) => dir.path),
- 'create temp dir');
- var dartPath = schedule(() {
- return tempDir.then((dir) {
- return new File(path.join(dir, 'test.dart')).writeAsString('''
- import 'dart:async';
- import 'dart:convert';
- import 'dart:io';
-
- var stdinLines = stdin
- .transform(UTF8.decoder)
- .transform(new LineSplitter());
-
- void main() {
- $script
- }
- ''').then((file) => file.path);
- });
- }, 'write script file');
-
- currentSchedule.onComplete.schedule(() {
- return tempDir.catchError((_) => null).then((dir) {
- if (dir == null) return null;
- return new Directory(dir).delete(recursive: true);
- });
- }, 'clean up temp dir');
-
- return new ScheduledProcess.start(Platform.executable,
- ['--checked', dartPath]);
-}
« no previous file with comments | « pkg/scheduled_test/test/scheduled_future_matchers_test.dart ('k') | pkg/scheduled_test/test/scheduled_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698