diff --git a/pkgs/test/CHANGELOG.md b/pkgs/test/CHANGELOG.md index 8e3b42940..b347424ea 100644 --- a/pkgs/test/CHANGELOG.md +++ b/pkgs/test/CHANGELOG.md @@ -3,6 +3,7 @@ * Simplify the initialization of the per-suite message channel within browser tests. See https://github.com/dart-lang/test/issues/2065 * Add a timeout to browser test suite loads. +* Fix running of browser tests that use deferred loaded libraries. ## 1.24.6 diff --git a/pkgs/test/pubspec.yaml b/pkgs/test/pubspec.yaml index 872b96aea..90463532d 100644 --- a/pkgs/test/pubspec.yaml +++ b/pkgs/test/pubspec.yaml @@ -35,7 +35,7 @@ dependencies: # Use an exact version until the test_api and test_core package are stable. test_api: 0.6.1 - test_core: 0.5.6 + test_core: 0.5.7 typed_data: ^1.3.0 web_socket_channel: ^2.0.0 diff --git a/pkgs/test/test/runner/browser/runner_test.dart b/pkgs/test/test/runner/browser/runner_test.dart index 322c24a7e..c55cbb884 100644 --- a/pkgs/test/test/runner/browser/runner_test.dart +++ b/pkgs/test/test/runner/browser/runner_test.dart @@ -921,4 +921,58 @@ void main() { await test.shouldExit(0); }, tags: 'chrome'); }); + + group('deferred loading', () { + test('can run browser tests with deferred library imports', () async { + await d.file('deferred.dart', ''' +int x = 1; +''').create(); + await d.file('test.dart', ''' +import 'package:test/test.dart'; + +import 'deferred.dart' deferred as d; + +void main() { + test("success", () async { + await d.loadLibrary(); + expect(d.x, 1); + }); +} +''').create(); + var test = await runTest(['-p', 'chrome', 'test.dart']); + + expect(test.stdout, emitsThrough(contains('+1: All tests passed!'))); + await test.shouldExit(0); + }, tags: 'chrome'); + + test('stack trace mapping works for deferred loaded libraries', () async { + await d.file('deferred.dart', ''' +int get x { + throw 'Oh no!'; +} +''').create(); + await d.file('test.dart', ''' +import 'package:test/test.dart'; + +import 'deferred.dart' deferred as d; + +void main() { + test("failure", () async { + await d.loadLibrary(); + expect(d.x, 1); + }); +} +''').create(); + + var test = await runTest(['-p', 'chrome', 'test.dart']); + expect( + test.stdout, + containsInOrder([ + 'Oh no!', + 'deferred.dart', + 'test.dart', + ])); + await test.shouldExit(1); + }, tags: 'chrome'); + }); } diff --git a/pkgs/test_core/CHANGELOG.md b/pkgs/test_core/CHANGELOG.md index 2a0b55ffe..dba17edd4 100644 --- a/pkgs/test_core/CHANGELOG.md +++ b/pkgs/test_core/CHANGELOG.md @@ -1,5 +1,8 @@ ## 0.5.7-wip +* Pass --disable-program-split to dart2js to fix tests which use deferred + loading. + ## 0.5.6 * Add support for discontinuing after the first failing test with `--fail-fast`. diff --git a/pkgs/test_core/lib/src/runner/dart2js_compiler_pool.dart b/pkgs/test_core/lib/src/runner/dart2js_compiler_pool.dart index c1bd159b4..a1e7fc8c4 100644 --- a/pkgs/test_core/lib/src/runner/dart2js_compiler_pool.dart +++ b/pkgs/test_core/lib/src/runner/dart2js_compiler_pool.dart @@ -53,6 +53,7 @@ class Dart2JsCompilerPool extends CompilerPool { wrapperPath, '--out=$path', '--packages=${await packageConfigUri}', + '--disable-program-split', ..._extraArgs, ...suiteConfig.dart2jsArgs ];