Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option of running frontend server tests in canary mode #2169

Merged
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
1 change: 1 addition & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion dwds/debug_extension/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dwds/debug_extension_mv3/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dwds/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions dwds/test/fixtures/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class TestContext {
bool isFlutterApp = false,
bool isInternalBuild = false,
List<String> experiments = const <String>[],
bool canaryFeatures = false,
}) async {
final sdkLayout = sdkConfigurationProvider.sdkLayout;

Expand Down Expand Up @@ -308,6 +309,7 @@ class TestContext {
outputPath: outputDir.path,
soundNullSafety: nullSafety == NullSafety.sound,
experiments: experiments,
canaryFeatures: canaryFeatures,
verbose: verboseCompiler,
sdkLayout: sdkLayout,
);
Expand Down
13 changes: 13 additions & 0 deletions dwds/test/fixtures/project.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<void> cleanUp() async {
await Process.run(
'dart',
['run', 'build_runner', 'clean'],
workingDirectory: absolutePackageDirectory,
);
}
}
102 changes: 102 additions & 0 deletions dwds/test/instances/instance_canary_test.dart
Original file line number Diff line number Diff line change
@@ -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');
});
});
});
});
}
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fixtures/_experimentSound/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fixtures/_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fixtures/_testCircular1/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fixtures/_testCircular1Sound/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fixtures/_testCircular2/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion fixtures/_testCircular2Sound/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion fixtures/_testPackage/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion fixtures/_testPackageSound/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion fixtures/_testSound/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fixtures/_webdevSmoke/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion fixtures/_webdevSoundSmoke/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions frontend_server_common/lib/src/frontend_server_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ class ResidentCompiler {
required this.platformDill,
required this.soundNullSafety,
this.experiments = const <String>[],
this.canaryFeatures = false,
required this.sdkLayout,
this.verbose = false,
CompilerMessageConsumer compilerMessageConsumer = defaultConsumer,
Expand All @@ -271,6 +272,7 @@ class ResidentCompiler {
final String platformDill;
final bool soundNullSafety;
final List<String> experiments;
final bool canaryFeatures;
final TestSdkLayout sdkLayout;
final bool verbose;

Expand Down Expand Up @@ -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',
];

Expand Down
2 changes: 2 additions & 0 deletions frontend_server_common/lib/src/resident_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ResidentWebRunner {
required this.outputPath,
required this.soundNullSafety,
this.experiments = const <String>[],
bool canaryFeatures = false,
required this.sdkLayout,
bool verbose = false,
}) {
Expand All @@ -47,6 +48,7 @@ class ResidentWebRunner {
fileSystemScheme: fileSystemScheme,
soundNullSafety: soundNullSafety,
experiments: experiments,
canaryFeatures: canaryFeatures,
sdkLayout: sdkLayout,
verbose: verbose,
);
Expand Down
18 changes: 15 additions & 3 deletions test_common/lib/sdk_asset_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ class SdkAssetGenerator {
final _logger = Logger('SdkAssetGenerator');

final FileSystem fileSystem;
final bool canaryFeatures;
final bool verbose;

late final TestSdkLayout sdkLayout;

SdkAssetGenerator({
this.fileSystem = const LocalFileSystem(),
required this.sdkLayout,
required this.canaryFeatures,
this.verbose = false,
});

Expand All @@ -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<void> _generateSdkJavaScript({required bool soundNullSafety}) async {
Future<void> _generateSdkJavaScript({
required bool soundNullSafety,
required bool canaryFeatures,
}) async {
Directory? outputDir;
try {
// Files to copy generated files to.
Expand Down Expand Up @@ -92,6 +103,7 @@ class SdkAssetGenerator {
'dart:core',
'-o',
jsPath,
if (canaryFeatures) '--canary',
];

final output = <String>[];
Expand Down
Loading
Loading