Skip to content

Commit

Permalink
Fix running browser tests in subdirectories and release 0.12.0-beta.10.
Browse files Browse the repository at this point in the history
R=kevmoo@google.com

Review URL: https://codereview.chromium.org//1098763004
  • Loading branch information
nex3 committed Apr 18, 2015
1 parent 5a9a8d8 commit 60c662d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 0.12.0-beta.10

* Fix running browser tests in subdirectories.

### 0.12.0-beta.9

* A browser test may use a custom HTML file. See [the README][custom html] for
Expand Down
7 changes: 4 additions & 3 deletions lib/src/runner/browser/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,11 @@ void main() {

// Link to the Dart wrapper on Dartium and the compiled JS version
// elsewhere.
var scriptBase =
"${HTML_ESCAPE.convert(p.basename(test))}.browser_test.dart";
var script = request.headers['user-agent'].contains('(Dart)')
? 'type="application/dart" '
'src="${HTML_ESCAPE.convert(test)}.browser_test.dart"'
: 'src="${HTML_ESCAPE.convert(test)}.browser_test.dart.js"';
? 'type="application/dart" src="$scriptBase"'
: 'src="$scriptBase.js"';

return new shelf.Response.ok('''
<!DOCTYPE html>
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.0-beta.9
version: 0.12.0-beta.10
author: Dart Team <misc@dartlang.org>
description: A library for writing dart unit tests.
homepage: https://github.com/dart-lang/test
Expand Down
9 changes: 9 additions & 0 deletions test/runner/browser/runner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,15 @@ void main() {
expect(result.exitCode, equals(0));
});

// Regression test; this broke in 0.12.0-beta.9.
test("on a file in a subdirectory", () {
new Directory(p.join(_sandbox, "dir")).createSync();
new File(p.join(_sandbox, "dir", "test.dart"))
.writeAsStringSync(_success);
var result = _runUnittest(["-p", "chrome", "dir/test.dart"]);
expect(result.exitCode, equals(0));
});

group("with a custom HTML file", () {
setUp(() {
new File(p.join(_sandbox, "test.dart")).writeAsStringSync("""
Expand Down
9 changes: 9 additions & 0 deletions test/runner/runner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,15 @@ $_usage"""));
]);
expect(result.stdout, contains("All tests passed!"));
});

// Regression test; this broke in 0.12.0-beta.9.
test("on a file in a subdirectory", () {
new Directory(p.join(_sandbox, "dir")).createSync();
new File(p.join(_sandbox, "dir", "test.dart"))
.writeAsStringSync(_success);
var result = _runUnittest(["dir/test.dart"]);
expect(result.exitCode, equals(0));
});
});

group("runs failing tests", () {
Expand Down

0 comments on commit 60c662d

Please sign in to comment.