Skip to content

Commit 2fcc1ba

Browse files
author
Anna Gringauze
authored
Add option of running frontend server tests in canary mode (#2169)
* Add an option to run wuth --canary flag to frontend server tests * Add tests * Simplfy tests and update min SDK version * Update changelog
1 parent 632763a commit 2fcc1ba

File tree

26 files changed

+196
-32
lines changed

26 files changed

+196
-32
lines changed

dwds/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 20.0.0-wip
22

33
- Require clients to specify the `basePath` on `AssetReader`. - [#2160](https://github.com/dart-lang/webdev/pull/2160)
4+
- Update SDK constraint to `>=3.1.0-254.0.dev <4.0.0`. - [#2169](https://github.com/dart-lang/webdev/pull/2169)
45

56
## 19.0.2
67

dwds/debug_extension/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: >-
66
A chrome extension for Dart debugging.
77
88
environment:
9-
sdk: ">=3.0.0-188.0.dev <4.0.0"
9+
sdk: ">=3.1.0-254.0.dev <4.0.0"
1010

1111
dependencies:
1212
async: ^2.3.0

dwds/debug_extension_mv3/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: >-
66
A Chrome extension for Dart debugging.
77
88
environment:
9-
sdk: ">=3.0.0-188.0.dev <4.0.0"
9+
sdk: ">=3.1.0-254.0.dev <4.0.0"
1010

1111
dependencies:
1212
built_value: ^8.3.0

dwds/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: >-
66
service protocol.
77
repository: https://github.com/dart-lang/webdev/tree/master/dwds
88
environment:
9-
sdk: ">=3.0.0-188.0.dev <4.0.0"
9+
sdk: ">=3.1.0-254.0.dev <4.0.0"
1010

1111
dependencies:
1212
async: ^2.9.0

dwds/test/fixtures/context.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ class TestContext {
148148
bool isFlutterApp = false,
149149
bool isInternalBuild = false,
150150
List<String> experiments = const <String>[],
151+
bool canaryFeatures = false,
151152
}) async {
152153
final sdkLayout = sdkConfigurationProvider.sdkLayout;
153154

@@ -308,6 +309,7 @@ class TestContext {
308309
outputPath: outputDir.path,
309310
soundNullSafety: nullSafety == NullSafety.sound,
310311
experiments: experiments,
312+
canaryFeatures: canaryFeatures,
311313
verbose: verboseCompiler,
312314
sdkLayout: sdkLayout,
313315
);

dwds/test/fixtures/project.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'dart:io';
6+
57
import 'package:path/path.dart' as p;
68

79
import 'package:test_common/utilities.dart';
@@ -221,4 +223,15 @@ class TestProject {
221223
// Verify that the web assets path has no starting slash:
222224
assert(!webAssetsPath.startsWith('/'));
223225
}
226+
227+
/// Clean up the project.
228+
/// Called when we need to rebuild sdk and the app from
229+
/// previous test configurations.
230+
Future<void> cleanUp() async {
231+
await Process.run(
232+
'dart',
233+
['run', 'build_runner', 'clean'],
234+
workingDirectory: absolutePackageDirectory,
235+
);
236+
}
224237
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
@Tags(['daily'])
6+
@Timeout(Duration(minutes: 2))
7+
8+
import 'package:dwds/src/debugging/inspector.dart';
9+
import 'package:dwds/src/loaders/strategy.dart';
10+
import 'package:test/test.dart';
11+
import 'package:test_common/logging.dart';
12+
import 'package:test_common/test_sdk_configuration.dart';
13+
14+
import '../fixtures/context.dart';
15+
import '../fixtures/project.dart';
16+
17+
void main() {
18+
// Enable verbose logging for debugging.
19+
final debug = false;
20+
21+
_runAllTests(
22+
canaryFeatures: true,
23+
compilationMode: CompilationMode.frontendServer,
24+
debug: debug,
25+
);
26+
}
27+
28+
void _runAllTests({
29+
required bool canaryFeatures,
30+
required CompilationMode compilationMode,
31+
required bool debug,
32+
}) {
33+
group('canaryFeatures: $canaryFeatures |', () {
34+
final provider = TestSdkConfigurationProvider(
35+
canaryFeatures: canaryFeatures,
36+
verbose: debug,
37+
);
38+
39+
final project = TestProject.testScopesWithSoundNullSafety;
40+
41+
setUpAll(() async {
42+
setCurrentLogWriter(debug: debug);
43+
// Cleanup project including compiled dart sdk.
44+
await project.cleanUp();
45+
});
46+
tearDownAll(provider.dispose);
47+
48+
group('$compilationMode |', () {
49+
final context = TestContext(project, provider);
50+
late AppInspector inspector;
51+
52+
setUpAll(() async {
53+
setCurrentLogWriter(debug: debug);
54+
await context.setUp(
55+
canaryFeatures: canaryFeatures,
56+
compilationMode: compilationMode,
57+
);
58+
final chromeProxyService = context.service;
59+
inspector = chromeProxyService.inspector;
60+
});
61+
62+
tearDownAll(() async {
63+
await context.tearDown();
64+
});
65+
66+
final url = 'org-dartlang-app:///example/scopes/main.dart';
67+
68+
String libraryName(CompilationMode compilationMode) =>
69+
compilationMode == CompilationMode.frontendServer
70+
? "example/scopes/main.dart"
71+
: "example/scopes/main";
72+
73+
String libraryVariableTypeExpression(
74+
String variable,
75+
CompilationMode compilationMode,
76+
) =>
77+
'''
78+
(function() {
79+
var dart = ${globalLoadStrategy.loadModuleSnippet}('dart_sdk').dart;
80+
var libraryName = '${libraryName(compilationMode)}';
81+
var library = dart.getModuleLibraries(libraryName)['$url'];
82+
var x = library['$variable'];
83+
return dart.getReifiedType(x);
84+
})();
85+
''';
86+
87+
group('compiler', () {
88+
setUp(() => setCurrentLogWriter(debug: debug));
89+
90+
test('uses new type system', () async {
91+
final remoteObject = await inspector.jsEvaluate(
92+
libraryVariableTypeExpression(
93+
'libraryPublicFinal',
94+
compilationMode,
95+
),
96+
);
97+
expect(remoteObject.json['className'], 'dart_rti.Rti.new');
98+
});
99+
});
100+
});
101+
});
102+
}

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: A web app example for webdev CLI.
44
publish_to: none
55

66
environment:
7-
sdk: ">=3.0.0-188.0.dev <4.0.0"
7+
sdk: ">=3.1.0-254.0.dev <4.0.0"
88

99
dev_dependencies:
1010
build_runner: ^2.4.0

fixtures/_experimentSound/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: >-
55
publish_to: none
66

77
environment:
8-
sdk: ">=3.0.0-188.0.dev<4.0.0"
8+
sdk: ">=3.1.0-254.0.dev<4.0.0"
99

1010
dependencies:
1111
intl: ^0.17.0

fixtures/_test/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description: >-
99
publish_to: none
1010

1111
environment:
12-
sdk: ">=3.0.0-188.0.dev <4.0.0"
12+
sdk: ">=3.1.0-254.0.dev <4.0.0"
1313

1414
dependencies:
1515
intl: ^0.17.0

0 commit comments

Comments
 (0)