diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 5c821405a0..b1b389bdc2 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -590,7 +590,8 @@ Future _runWebUnitTests() async { Future _runWebIntegrationTests() async { await _runWebStackTraceTest('profile'); await _runWebStackTraceTest('release'); - await _runWebDebugStackTraceTest(); + await _runWebDebugTest('lib/stack_trace.dart'); + await _runWebDebugTest('test/test.dart'); } Future _runWebStackTraceTest(String buildMode) async { @@ -636,7 +637,7 @@ Future _runWebStackTraceTest(String buildMode) async { /// Debug mode is special because `flutter build web` doesn't build in debug mode. /// /// Instead, we use `flutter run --debug` and sniff out the standard output. -Future _runWebDebugStackTraceTest() async { +Future _runWebDebugTest(String target) async { final String testAppDirectory = path.join(flutterRoot, 'dev', 'integration_tests', 'web'); final CapturedOutput output = CapturedOutput(); bool success = false; @@ -648,7 +649,8 @@ Future _runWebDebugStackTraceTest() async { '-d', 'chrome', '--web-run-headless', - 'lib/stack_trace.dart', + '-t', + target, ], output: output, outputMode: OutputMode.capture, diff --git a/dev/integration_tests/web/lib/a.dart b/dev/integration_tests/web/lib/a.dart new file mode 100644 index 0000000000..4b209ef757 --- /dev/null +++ b/dev/integration_tests/web/lib/a.dart @@ -0,0 +1,5 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const String message = 'a'; diff --git a/dev/integration_tests/web/lib/b.dart b/dev/integration_tests/web/lib/b.dart new file mode 100644 index 0000000000..edb667ea30 --- /dev/null +++ b/dev/integration_tests/web/lib/b.dart @@ -0,0 +1,5 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const String message = 'b'; diff --git a/dev/integration_tests/web/lib/c.dart b/dev/integration_tests/web/lib/c.dart new file mode 100644 index 0000000000..000e7323c3 --- /dev/null +++ b/dev/integration_tests/web/lib/c.dart @@ -0,0 +1,5 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const String message = 'c'; diff --git a/dev/integration_tests/web/lib/d.dart b/dev/integration_tests/web/lib/d.dart new file mode 100644 index 0000000000..c4a3de83c3 --- /dev/null +++ b/dev/integration_tests/web/lib/d.dart @@ -0,0 +1,5 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const String message = 'd'; diff --git a/dev/integration_tests/web/test/test.dart b/dev/integration_tests/web/test/test.dart new file mode 100644 index 0000000000..e184f93fdc --- /dev/null +++ b/dev/integration_tests/web/test/test.dart @@ -0,0 +1,16 @@ +// Copyright 2014 The Flutter 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 'package:web_integration/a.dart' + if (dart.library.io) 'package:web_integration/b.dart' as message1; +import 'package:web_integration/c.dart' + if (dart.library.html) 'package:web_integration/d.dart' as message2; + +void main() { + if (message1.message == 'a' && message2.message == 'd') { + print('--- TEST SUCCEEDED ---'); + } else { + print('--- TEST FAILED ---'); + } +} diff --git a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart index 0750c53522..6073301bb7 100644 --- a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart +++ b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart @@ -573,7 +573,13 @@ class _ResidentWebRunner extends ResidentWebRunner { .childFile('generated_plugin_registrant.dart') .absolute.path; final Uri generatedImport = packageUriMapper.map(generatedPath); - final String importedEntrypoint = packageUriMapper.map(main).toString() ?? 'file://$main'; + String importedEntrypoint = packageUriMapper.map(main)?.toString(); + // Special handling for entrypoints that are not under lib, such as test scripts. + if (importedEntrypoint == null) { + final String parent = globals.fs.file(main).parent.path; + flutterDevices.first.generator.addFileSystemRoot(parent); + importedEntrypoint = 'org-dartlang-app:///${globals.fs.path.basename(main)}'; + } final String entrypoint = [ 'import "$importedEntrypoint" as entrypoint;', diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart index 7641d18e88..dde12a49c4 100644 --- a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart @@ -427,9 +427,8 @@ void main() { Usage: () => MockFlutterUsage(), })); - test('web resident runner iss debuggable', () => testbed.run(() { + test('web resident runner is debuggable', () => testbed.run(() { expect(residentWebRunner.debuggingEnabled, true); - }, overrides: { })); test('Exits when initial compile fails', () => testbed.run(() async {