diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md index 499511c16..122e1a900 100644 --- a/dwds/CHANGELOG.md +++ b/dwds/CHANGELOG.md @@ -1,6 +1,7 @@ ## 20.0.0-wip - Require clients to specify the `basePath` on `AssetReader`. - [#2160](https://github.com/dart-lang/webdev/pull/2160) +- Update SDK constraint to `>=3.1.0-254.0.dev <4.0.0`. - [#2169](https://github.com/dart-lang/webdev/pull/2169) ## 19.0.2 diff --git a/dwds/debug_extension/pubspec.yaml b/dwds/debug_extension/pubspec.yaml index 9a3ecdf6a..d7b39e86d 100644 --- a/dwds/debug_extension/pubspec.yaml +++ b/dwds/debug_extension/pubspec.yaml @@ -6,7 +6,7 @@ description: >- A chrome extension for Dart debugging. environment: - sdk: ">=3.0.0-188.0.dev <4.0.0" + sdk: ">=3.1.0-254.0.dev <4.0.0" dependencies: async: ^2.3.0 diff --git a/dwds/debug_extension_mv3/pubspec.yaml b/dwds/debug_extension_mv3/pubspec.yaml index 60cae0365..332587a5b 100644 --- a/dwds/debug_extension_mv3/pubspec.yaml +++ b/dwds/debug_extension_mv3/pubspec.yaml @@ -6,7 +6,7 @@ description: >- A Chrome extension for Dart debugging. environment: - sdk: ">=3.0.0-188.0.dev <4.0.0" + sdk: ">=3.1.0-254.0.dev <4.0.0" dependencies: built_value: ^8.3.0 diff --git a/dwds/pubspec.yaml b/dwds/pubspec.yaml index 2f62a60ec..e11e5c1ac 100644 --- a/dwds/pubspec.yaml +++ b/dwds/pubspec.yaml @@ -6,7 +6,7 @@ description: >- service protocol. repository: https://github.com/dart-lang/webdev/tree/master/dwds environment: - sdk: ">=3.0.0-188.0.dev <4.0.0" + sdk: ">=3.1.0-254.0.dev <4.0.0" dependencies: async: ^2.9.0 diff --git a/dwds/test/fixtures/context.dart b/dwds/test/fixtures/context.dart index c6285bfb6..dc574d78b 100644 --- a/dwds/test/fixtures/context.dart +++ b/dwds/test/fixtures/context.dart @@ -148,6 +148,7 @@ class TestContext { bool isFlutterApp = false, bool isInternalBuild = false, List experiments = const [], + bool canaryFeatures = false, }) async { final sdkLayout = sdkConfigurationProvider.sdkLayout; @@ -308,6 +309,7 @@ class TestContext { outputPath: outputDir.path, soundNullSafety: nullSafety == NullSafety.sound, experiments: experiments, + canaryFeatures: canaryFeatures, verbose: verboseCompiler, sdkLayout: sdkLayout, ); diff --git a/dwds/test/fixtures/project.dart b/dwds/test/fixtures/project.dart index dea432657..0d5458b92 100644 --- a/dwds/test/fixtures/project.dart +++ b/dwds/test/fixtures/project.dart @@ -2,6 +2,8 @@ // 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. +import 'dart:io'; + import 'package:path/path.dart' as p; import 'package:test_common/utilities.dart'; @@ -221,4 +223,15 @@ class TestProject { // Verify that the web assets path has no starting slash: assert(!webAssetsPath.startsWith('/')); } + + /// Clean up the project. + /// Called when we need to rebuild sdk and the app from + /// previous test configurations. + Future cleanUp() async { + await Process.run( + 'dart', + ['run', 'build_runner', 'clean'], + workingDirectory: absolutePackageDirectory, + ); + } } diff --git a/dwds/test/instances/instance_canary_test.dart b/dwds/test/instances/instance_canary_test.dart new file mode 100644 index 000000000..fd73561de --- /dev/null +++ b/dwds/test/instances/instance_canary_test.dart @@ -0,0 +1,102 @@ +// Copyright (c) 2019, 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. + +@Tags(['daily']) +@Timeout(Duration(minutes: 2)) + +import 'package:dwds/src/debugging/inspector.dart'; +import 'package:dwds/src/loaders/strategy.dart'; +import 'package:test/test.dart'; +import 'package:test_common/logging.dart'; +import 'package:test_common/test_sdk_configuration.dart'; + +import '../fixtures/context.dart'; +import '../fixtures/project.dart'; + +void main() { + // Enable verbose logging for debugging. + final debug = false; + + _runAllTests( + canaryFeatures: true, + compilationMode: CompilationMode.frontendServer, + debug: debug, + ); +} + +void _runAllTests({ + required bool canaryFeatures, + required CompilationMode compilationMode, + required bool debug, +}) { + group('canaryFeatures: $canaryFeatures |', () { + final provider = TestSdkConfigurationProvider( + canaryFeatures: canaryFeatures, + verbose: debug, + ); + + final project = TestProject.testScopesWithSoundNullSafety; + + setUpAll(() async { + setCurrentLogWriter(debug: debug); + // Cleanup project including compiled dart sdk. + await project.cleanUp(); + }); + tearDownAll(provider.dispose); + + group('$compilationMode |', () { + final context = TestContext(project, provider); + late AppInspector inspector; + + setUpAll(() async { + setCurrentLogWriter(debug: debug); + await context.setUp( + canaryFeatures: canaryFeatures, + compilationMode: compilationMode, + ); + final chromeProxyService = context.service; + inspector = chromeProxyService.inspector; + }); + + tearDownAll(() async { + await context.tearDown(); + }); + + final url = 'org-dartlang-app:///example/scopes/main.dart'; + + String libraryName(CompilationMode compilationMode) => + compilationMode == CompilationMode.frontendServer + ? "example/scopes/main.dart" + : "example/scopes/main"; + + String libraryVariableTypeExpression( + String variable, + CompilationMode compilationMode, + ) => + ''' + (function() { + var dart = ${globalLoadStrategy.loadModuleSnippet}('dart_sdk').dart; + var libraryName = '${libraryName(compilationMode)}'; + var library = dart.getModuleLibraries(libraryName)['$url']; + var x = library['$variable']; + return dart.getReifiedType(x); + })(); + '''; + + group('compiler', () { + setUp(() => setCurrentLogWriter(debug: debug)); + + test('uses new type system', () async { + final remoteObject = await inspector.jsEvaluate( + libraryVariableTypeExpression( + 'libraryPublicFinal', + compilationMode, + ), + ); + expect(remoteObject.json['className'], 'dart_rti.Rti.new'); + }); + }); + }); + }); +} diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 9bfd9c227..14735e63d 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,7 +4,7 @@ description: A web app example for webdev CLI. publish_to: none environment: - sdk: ">=3.0.0-188.0.dev <4.0.0" + sdk: ">=3.1.0-254.0.dev <4.0.0" dev_dependencies: build_runner: ^2.4.0 diff --git a/fixtures/_experimentSound/pubspec.yaml b/fixtures/_experimentSound/pubspec.yaml index c86678ce3..08179dc98 100644 --- a/fixtures/_experimentSound/pubspec.yaml +++ b/fixtures/_experimentSound/pubspec.yaml @@ -5,7 +5,7 @@ description: >- publish_to: none environment: - sdk: ">=3.0.0-188.0.dev<4.0.0" + sdk: ">=3.1.0-254.0.dev<4.0.0" dependencies: intl: ^0.17.0 diff --git a/fixtures/_test/pubspec.yaml b/fixtures/_test/pubspec.yaml index 4bce18d2e..5969c1891 100644 --- a/fixtures/_test/pubspec.yaml +++ b/fixtures/_test/pubspec.yaml @@ -9,7 +9,7 @@ description: >- publish_to: none environment: - sdk: ">=3.0.0-188.0.dev <4.0.0" + sdk: ">=3.1.0-254.0.dev <4.0.0" dependencies: intl: ^0.17.0 diff --git a/fixtures/_testCircular1/pubspec.yaml b/fixtures/_testCircular1/pubspec.yaml index c9c742937..8fc4b93ee 100644 --- a/fixtures/_testCircular1/pubspec.yaml +++ b/fixtures/_testCircular1/pubspec.yaml @@ -9,7 +9,7 @@ description: >- publish_to: none environment: - sdk: ">=3.0.0-188.0.dev <4.0.0" + sdk: ">=3.1.0-254.0.dev <4.0.0" dependencies: intl: ^0.17.0 diff --git a/fixtures/_testCircular1Sound/pubspec.yaml b/fixtures/_testCircular1Sound/pubspec.yaml index e0718b8a8..d4c59761c 100644 --- a/fixtures/_testCircular1Sound/pubspec.yaml +++ b/fixtures/_testCircular1Sound/pubspec.yaml @@ -5,7 +5,7 @@ description: >- publish_to: none environment: - sdk: ">=3.0.0-188.0.dev <4.0.0" + sdk: ">=3.1.0-254.0.dev <4.0.0" dependencies: intl: ^0.17.0 diff --git a/fixtures/_testCircular2/pubspec.yaml b/fixtures/_testCircular2/pubspec.yaml index 00c7ff4dd..8c67a6ec2 100644 --- a/fixtures/_testCircular2/pubspec.yaml +++ b/fixtures/_testCircular2/pubspec.yaml @@ -9,7 +9,7 @@ description: >- publish_to: none environment: - sdk: ">=3.0.0-188.0.dev <4.0.0" + sdk: ">=3.1.0-254.0.dev <4.0.0" dependencies: _test_circular1: diff --git a/fixtures/_testCircular2Sound/pubspec.yaml b/fixtures/_testCircular2Sound/pubspec.yaml index dfa4fcaed..143f222e9 100644 --- a/fixtures/_testCircular2Sound/pubspec.yaml +++ b/fixtures/_testCircular2Sound/pubspec.yaml @@ -5,7 +5,7 @@ description: >- publish_to: none environment: - sdk: ">=3.0.0-188.0.dev <4.0.0" + sdk: ">=3.1.0-254.0.dev <4.0.0" dependencies: _test_circular1_sound: diff --git a/fixtures/_testPackage/pubspec.yaml b/fixtures/_testPackage/pubspec.yaml index 2352e0fbd..7c3ec06ef 100644 --- a/fixtures/_testPackage/pubspec.yaml +++ b/fixtures/_testPackage/pubspec.yaml @@ -9,7 +9,7 @@ description: >- publish_to: none environment: - sdk: ">=3.0.0-188.0.dev<4.0.0" + sdk: ">=3.1.0-254.0.dev<4.0.0" dependencies: _test: diff --git a/fixtures/_testPackageSound/pubspec.yaml b/fixtures/_testPackageSound/pubspec.yaml index 4207b8667..c36333670 100644 --- a/fixtures/_testPackageSound/pubspec.yaml +++ b/fixtures/_testPackageSound/pubspec.yaml @@ -5,7 +5,7 @@ description: >- publish_to: none environment: - sdk: ">=3.0.0-188.0.dev <4.0.0" + sdk: ">=3.1.0-254.0.dev <4.0.0" dependencies: _test_sound: diff --git a/fixtures/_testSound/pubspec.yaml b/fixtures/_testSound/pubspec.yaml index 6f161e844..ce6839f55 100644 --- a/fixtures/_testSound/pubspec.yaml +++ b/fixtures/_testSound/pubspec.yaml @@ -5,7 +5,7 @@ description: >- publish_to: none environment: - sdk: ">=3.0.0-188.0.dev <4.0.0" + sdk: ">=3.1.0-254.0.dev <4.0.0" dependencies: intl: ^0.17.0 diff --git a/fixtures/_webdevSmoke/pubspec.yaml b/fixtures/_webdevSmoke/pubspec.yaml index 4dc1ce0f5..493debe0e 100644 --- a/fixtures/_webdevSmoke/pubspec.yaml +++ b/fixtures/_webdevSmoke/pubspec.yaml @@ -14,7 +14,7 @@ publish_to: none # and build_web_compilers constraint should match those defined # in pubspec.dart. environment: - sdk: ">=3.0.0-188.0.dev <4.0.0" + sdk: ">=3.1.0-254.0.dev <4.0.0" dev_dependencies: build_runner: '>=1.6.2 <3.0.0' diff --git a/fixtures/_webdevSoundSmoke/pubspec.yaml b/fixtures/_webdevSoundSmoke/pubspec.yaml index 9a69fc6bf..82d59880c 100644 --- a/fixtures/_webdevSoundSmoke/pubspec.yaml +++ b/fixtures/_webdevSoundSmoke/pubspec.yaml @@ -4,7 +4,7 @@ description: A test fixture for webdev testing with sound support. publish_to: none environment: - sdk: ">=3.0.0-188.0.dev <4.0.0" + sdk: ">=3.1.0-254.0.dev <4.0.0" dev_dependencies: build_runner: ^2.4.0 diff --git a/frontend_server_common/lib/src/frontend_server_client.dart b/frontend_server_common/lib/src/frontend_server_client.dart index 3a5300d23..0a7be231a 100644 --- a/frontend_server_common/lib/src/frontend_server_client.dart +++ b/frontend_server_common/lib/src/frontend_server_client.dart @@ -258,6 +258,7 @@ class ResidentCompiler { required this.platformDill, required this.soundNullSafety, this.experiments = const [], + this.canaryFeatures = false, required this.sdkLayout, this.verbose = false, CompilerMessageConsumer compilerMessageConsumer = defaultConsumer, @@ -271,6 +272,7 @@ class ResidentCompiler { final String platformDill; final bool soundNullSafety; final List experiments; + final bool canaryFeatures; final TestSdkLayout sdkLayout; final bool verbose; @@ -391,6 +393,7 @@ class ResidentCompiler { '--experimental-emit-debug-metadata', soundNullSafety ? '--sound-null-safety' : '--no-sound-null-safety', for (final experiment in experiments) '--enable-experiment=$experiment', + if (canaryFeatures) '--dartdevc-canary', if (verbose) '--verbose', ]; diff --git a/frontend_server_common/lib/src/resident_runner.dart b/frontend_server_common/lib/src/resident_runner.dart index 826fc6a38..fdf2e6b1c 100644 --- a/frontend_server_common/lib/src/resident_runner.dart +++ b/frontend_server_common/lib/src/resident_runner.dart @@ -30,6 +30,7 @@ class ResidentWebRunner { required this.outputPath, required this.soundNullSafety, this.experiments = const [], + bool canaryFeatures = false, required this.sdkLayout, bool verbose = false, }) { @@ -47,6 +48,7 @@ class ResidentWebRunner { fileSystemScheme: fileSystemScheme, soundNullSafety: soundNullSafety, experiments: experiments, + canaryFeatures: canaryFeatures, sdkLayout: sdkLayout, verbose: verbose, ); diff --git a/test_common/lib/sdk_asset_generator.dart b/test_common/lib/sdk_asset_generator.dart index e9584e24d..16dc7be8e 100644 --- a/test_common/lib/sdk_asset_generator.dart +++ b/test_common/lib/sdk_asset_generator.dart @@ -17,6 +17,7 @@ class SdkAssetGenerator { final _logger = Logger('SdkAssetGenerator'); final FileSystem fileSystem; + final bool canaryFeatures; final bool verbose; late final TestSdkLayout sdkLayout; @@ -24,6 +25,7 @@ class SdkAssetGenerator { SdkAssetGenerator({ this.fileSystem = const LocalFileSystem(), required this.sdkLayout, + required this.canaryFeatures, this.verbose = false, }); @@ -36,15 +38,24 @@ class SdkAssetGenerator { // normally generated by setup tools and their builds, // i.e. flutter SDK or build_web_compilers. // Generate missing files for tests if needed. - await _generateSdkJavaScript(soundNullSafety: true); + await _generateSdkJavaScript( + soundNullSafety: true, + canaryFeatures: canaryFeatures, + ); // SDK does not contain any weak assets, generate them. - await _generateSdkJavaScript(soundNullSafety: false); + await _generateSdkJavaScript( + soundNullSafety: false, + canaryFeatures: canaryFeatures, + ); await _generateSdkSummary(soundNullSafety: false); } } - Future _generateSdkJavaScript({required bool soundNullSafety}) async { + Future _generateSdkJavaScript({ + required bool soundNullSafety, + required bool canaryFeatures, + }) async { Directory? outputDir; try { // Files to copy generated files to. @@ -92,6 +103,7 @@ class SdkAssetGenerator { 'dart:core', '-o', jsPath, + if (canaryFeatures) '--canary', ]; final output = []; diff --git a/test_common/lib/test_sdk_configuration.dart b/test_common/lib/test_sdk_configuration.dart index b80c9d967..767e5fb3e 100644 --- a/test_common/lib/test_sdk_configuration.dart +++ b/test_common/lib/test_sdk_configuration.dart @@ -24,12 +24,17 @@ class TestSdkConfigurationProvider extends SdkConfigurationProvider { final _logger = Logger('TestSdkConfigurationProvider'); final bool _verbose; + final bool _canaryFeatures; late final Directory _sdkDirectory; SdkConfiguration? _configuration; late final TestSdkLayout sdkLayout; - TestSdkConfigurationProvider({bool verbose = false}) : _verbose = verbose { + TestSdkConfigurationProvider({ + bool canaryFeatures = false, + bool verbose = false, + }) : _canaryFeatures = canaryFeatures, + _verbose = verbose { _sdkDirectory = Directory.systemTemp.createTempSync('sdk copy'); sdkLayout = TestSdkLayout.createDefault(_sdkDirectory.path); } @@ -56,6 +61,7 @@ class TestSdkConfigurationProvider extends SdkConfigurationProvider { try { final assetGenerator = SdkAssetGenerator( sdkLayout: sdkLayout, + canaryFeatures: _canaryFeatures, verbose: _verbose, ); diff --git a/test_common/test/sdk_asset_generator_test.dart b/test_common/test/sdk_asset_generator_test.dart index 79c98df22..fcbcfa3b5 100644 --- a/test_common/test/sdk_asset_generator_test.dart +++ b/test_common/test/sdk_asset_generator_test.dart @@ -16,21 +16,21 @@ void main() { group('SDK asset generator', () { final bool debug = false; - late final Directory tempDir; + late Directory tempDir; late String sdkDirectory; - late final String soundSdkSummaryPath; - late final String compilerWorkerPath; + late String soundSdkSummaryPath; + late String compilerWorkerPath; // Missing sound assets - late final String soundSdkFullDillPath; - late final String soundSdkJsPath; - late final String soundSdkJsMapPath; + late String soundSdkFullDillPath; + late String soundSdkJsPath; + late String soundSdkJsMapPath; // Missing weak assets - late final String weakSdkSummaryPath; - late final String weakSdkFullDillPath; - late final String weakSdkJsPath; - late final String weakSdkJsMapPath; + late String weakSdkSummaryPath; + late String weakSdkFullDillPath; + late String weakSdkJsPath; + late String weakSdkJsMapPath; setUp(() async { setCurrentLogWriter(debug: debug); @@ -75,8 +75,11 @@ void main() { final sdkLayout = TestSdkLayout.createDefault(sdkDirectory); final configuration = TestSdkLayout.createConfiguration(sdkLayout); - final assetGenerator = - SdkAssetGenerator(sdkLayout: sdkLayout, verbose: true); + final assetGenerator = SdkAssetGenerator( + sdkLayout: sdkLayout, + verbose: true, + canaryFeatures: false, + ); await assetGenerator.generateSdkAssets(); // Make sure SDK configuration and asset generator agree on the file paths. @@ -108,6 +111,24 @@ void main() { expect(sdkLayout.weakJsPath, _exists); expect(sdkLayout.weakJsMapPath, _exists); }); + + test('Can generate missing SDK assets with canary features enabled', + () async { + final sdkLayout = TestSdkLayout.createDefault(sdkDirectory); + + final assetGenerator = SdkAssetGenerator( + sdkLayout: sdkLayout, + verbose: true, + canaryFeatures: true, + ); + await assetGenerator.generateSdkAssets(); + + final soundSdk = File(soundSdkJsPath).readAsStringSync(); + expect(soundSdk, contains('canary')); + + final weakSdk = File(weakSdkJsPath).readAsStringSync(); + expect(weakSdk, contains('canary')); + }); }); } diff --git a/webdev/CHANGELOG.md b/webdev/CHANGELOG.md index cb77956f8..8563e5438 100644 --- a/webdev/CHANGELOG.md +++ b/webdev/CHANGELOG.md @@ -1,5 +1,7 @@ ## 3.0.6-wip +- Update SDK constraint to `>=3.1.0-254.0.dev <4.0.0`. + ## 3.0.5 - Update `dwds` constraint to `19.0.1`. diff --git a/webdev/pubspec.yaml b/webdev/pubspec.yaml index 741be296d..d242be2a3 100644 --- a/webdev/pubspec.yaml +++ b/webdev/pubspec.yaml @@ -8,7 +8,7 @@ description: >- features for users and tools to build and deploy web applications with Dart. repository: https://github.com/dart-lang/webdev/tree/master/webdev environment: - sdk: ">=3.0.0-188.0.dev <4.0.0" + sdk: ">=3.1.0-254.0.dev <4.0.0" dependencies: args: ^2.3.1