Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.12.32+1

* Fix a bug that broke content shell on Dart 1.24.

## 0.12.32

* Add an `include` configuration field which specifies the path to another
Expand Down
14 changes: 0 additions & 14 deletions lib/src/backend/suite_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// 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.

// Prefix this import to avoid accidentally using IO stuff in cross-platform
// contexts.
import '../util/io.dart' as io;
import 'operating_system.dart';
import 'runtime.dart';

Expand Down Expand Up @@ -34,17 +31,6 @@ class SuitePlatform {
}
}

/// Creates a new platform with the given [runtime] and [os] and [inGoogle]
/// determined using `dart:io`.
///
/// If [runtime] is a browser, this will set [os] to [OperatingSystem.none].
///
/// Throws an [UnsupportedError] if called in a context where `dart:io` is
/// unavailable.
SuitePlatform.current(this.runtime)
: os = runtime.isBrowser ? OperatingSystem.none : io.currentOS,
inGoogle = io.inGoogle;

/// Converts a JSON-safe representation generated by [serialize] back into a
/// [SuitePlatform].
factory SuitePlatform.deserialize(Object serialized) {
Expand Down
6 changes: 2 additions & 4 deletions lib/src/runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ class Runner {
var unsupportedRuntimes = _config.suiteDefaults.runtimes
.map(_loader.findRuntime)
.where((runtime) =>
runtime != null &&
!testOn.evaluate(new SuitePlatform.current(runtime)))
runtime != null && !testOn.evaluate(currentPlatform(runtime)))
.toList();
if (unsupportedRuntimes.isEmpty) return;

Expand All @@ -147,8 +146,7 @@ class Runner {
if (unsupportedBrowsers.isNotEmpty) {
var supportsAnyBrowser = _loader.allRuntimes
.where((runtime) => runtime.isBrowser)
.any(
(runtime) => testOn.evaluate(new SuitePlatform.current(runtime)));
.any((runtime) => testOn.evaluate(currentPlatform(runtime)));

if (supportsAnyBrowser) {
unsupportedNames
Expand Down
4 changes: 2 additions & 2 deletions lib/src/runner/browser/browser_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:stream_channel/stream_channel.dart';
import 'package:web_socket_channel/web_socket_channel.dart';

import '../../backend/runtime.dart';
import '../../backend/suite_platform.dart';
import '../../util/io.dart';
import '../../util/stack_trace_mapper.dart';
import '../application_exception.dart';
import '../configuration/suite.dart';
Expand Down Expand Up @@ -242,7 +242,7 @@ class BrowserManager {
});

try {
controller = deserializeSuite(path, new SuitePlatform.current(_runtime),
controller = deserializeSuite(path, currentPlatform(_runtime),
suiteConfig, await _environment, suiteChannel, message);

controller.channel("test.browser.mapper").sink.add(mapper?.serialize());
Expand Down
3 changes: 2 additions & 1 deletion lib/src/runner/load_suite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import '../backend/suite.dart';
import '../backend/suite_platform.dart';
import '../backend/test.dart';
import '../backend/runtime.dart';
import '../util/io.dart';
import '../utils.dart';
import 'configuration/suite.dart';
import 'load_exception.dart';
Expand Down Expand Up @@ -122,7 +123,7 @@ class LoadSuite extends Suite implements RunnerSuite {
return new LoadSuite(
"loading ${exception.path}",
config ?? SuiteConfiguration.empty,
platform ?? new SuitePlatform.current(Runtime.vm),
platform ?? currentPlatform(Runtime.vm),
() => new Future.error(exception, stackTrace),
path: exception.path);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/src/runner/loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import 'package:yaml/yaml.dart';
import '../backend/group.dart';
import '../backend/invoker.dart';
import '../backend/runtime.dart';
import '../backend/suite_platform.dart';
import '../util/io.dart';
import 'browser/platform.dart';
import 'configuration.dart';
Expand Down Expand Up @@ -223,7 +222,7 @@ class Loader {
var runtime = findRuntime(runtimeName);
assert(runtime != null, 'Unknown platform "$runtimeName".');

var platform = new SuitePlatform.current(runtime);
var platform = currentPlatform(runtime);
if (!suiteConfig.metadata.testOn.evaluate(platform)) {
continue;
}
Expand Down
13 changes: 13 additions & 0 deletions lib/src/util/io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import 'package:async/async.dart';
import 'package:path/path.dart' as p;

import '../backend/operating_system.dart';
import '../backend/runtime.dart';
import '../backend/suite_platform.dart';
import '../utils.dart';

/// The ASCII code for a newline character.
Expand Down Expand Up @@ -50,6 +52,17 @@ final OperatingSystem currentOS = (() {
throw new UnsupportedError('Unsupported operating system "$name".');
})();

// TODO(nweiz): Make this `new SuitePlatform.current()` once we only support
// Dart 2 and we can import `dart:io` from within cross-platform libraries. See
// commit 4ffda6d2.
/// Returns a [SuitePlatform] with the given [runtime], and with [os] and
/// [inGoogle] determined automatically.
///
/// If [runtime] is a browser, this will set [os] to [OperatingSystem.none].
SuitePlatform currentPlatform(Runtime runtime) => new SuitePlatform(runtime,
os: runtime.isBrowser ? OperatingSystem.none : currentOS,
inGoogle: inGoogle);

/// A queue of lines of standard input.
final stdinLines = new StreamQueue(lineSplitter.bind(stdin));

Expand Down
36 changes: 16 additions & 20 deletions lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ import 'dart:typed_data';
import 'package:async/async.dart';
import 'package:collection/collection.dart';
import 'package:matcher/matcher.dart';
import 'package:path/path.dart' as p;
import 'package:stream_channel/stream_channel.dart';
import 'package:term_glyph/term_glyph.dart' as glyph;

import 'backend/invoker.dart';
import 'backend/operating_system.dart';
// Prefix this import to avoid accidentally using IO stuff in cross-platform
// contexts.
import 'util/io.dart' as io;

/// A typedef for a possibly-asynchronous function.
///
Expand Down Expand Up @@ -51,16 +49,24 @@ final _exceptionPrefix = new RegExp(r'^([A-Z][a-zA-Z]*)?(Exception|Error): ');
/// A regular expression matching a single vowel.
final _vowel = new RegExp('[aeiou]');

/// Returns the best guess for the current operating system without relying on
/// Directories that are specific to OS X.
///
/// This is used to try to distinguish OS X and Linux in [currentOSGuess].
final _macOSDirectories = new Set<String>.from(
["/Applications", "/Library", "/Network", "/System", "/Users"]);

/// Returns the best guess for the current operating system without using
/// `dart:io`.
///
/// This is useful for running test files directly and skipping tests as
/// appropriate.
final currentOSGuess = _ifSupported(() => io.currentOS, OperatingSystem.none);

/// Returns the best guess for whether we're running on internal Google
/// infrastructure without relying on `dart:io`.
final inGoogleGuess = _ifSupported(() => io.inGoogle, false);
/// appropriate. The only OS-specific information we have is the current path,
/// which we try to use to figure out the OS.
final OperatingSystem currentOSGuess = (() {
if (p.style == p.Style.url) return OperatingSystem.none;
if (p.style == p.Style.windows) return OperatingSystem.windows;
if (_macOSDirectories.any(p.current.startsWith)) return OperatingSystem.macOS;
return OperatingSystem.linux;
})();

/// A regular expression matching a hyphenated identifier.
///
Expand Down Expand Up @@ -90,16 +96,6 @@ class Pair<E, F> {
int get hashCode => first.hashCode ^ last.hashCode;
}

/// Returns [callback]'s return value, unless it throws an [UnsupportedError] in
/// which case returns [fallback].
T _ifSupported<T>(T callback(), T fallback) {
try {
return callback();
} on UnsupportedError {
return fallback;
}
}

/// Get a string description of an exception.
///
/// Many exceptions include the exception class name at the beginning of their
Expand Down
3 changes: 1 addition & 2 deletions lib/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ Declarer get _declarer {
const PluginEnvironment(),
SuiteConfiguration.empty,
_globalDeclarer.build(),
new SuitePlatform(Runtime.vm,
os: currentOSGuess, inGoogle: inGoogleGuess),
new SuitePlatform(Runtime.vm, os: currentOSGuess),
path: p.prettyUri(Uri.base));

var engine = new Engine();
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: test
version: 0.12.32
version: 0.12.32+1
author: Dart Team <misc@dartlang.org>
description: A library for writing dart unit tests.
homepage: https://github.com/dart-lang/test
Expand Down