Skip to content

Commit 0f893e6

Browse files
author
Anna Gringauze
authored
Move project definitions into a separate class (#1975)
* Validate only needed summaries in expression_compiler_service * Move test project definitions to a separate class * Address CR comments
1 parent a942b5f commit 0f893e6

36 files changed

+396
-452
lines changed

dwds/test/build_daemon_breakpoint_test.dart

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,16 @@
66
@Timeout(Duration(minutes: 2))
77
import 'dart:async';
88

9-
import 'package:dwds/src/connections/debug_connection.dart';
109
import 'package:dwds/src/services/chrome_proxy_service.dart';
1110
import 'package:test/test.dart';
1211
import 'package:vm_service/vm_service.dart';
13-
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
1412

1513
import 'fixtures/context.dart';
14+
import 'fixtures/project.dart';
1615

17-
final context = TestContext.withSoundNullSafety(
18-
packageName: '_testPackageSound',
19-
webAssetsPath: 'web',
20-
dartEntryFileName: 'main.dart',
21-
htmlEntryFileName: 'index.html',
22-
);
16+
final context = TestContext(TestProject.testPackageWithSoundNullSafety());
2317

24-
ChromeProxyService get service =>
25-
fetchChromeProxyService(context.debugConnection);
26-
WipConnection get tabConnection => context.tabConnection;
18+
ChromeProxyService get service => context.service;
2719

2820
void main() {
2921
group('shared context', () {

dwds/test/build_daemon_callstack_test.dart

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,13 @@
66
@Timeout(Duration(minutes: 2))
77
import 'dart:async';
88

9-
import 'package:dwds/src/connections/debug_connection.dart';
109
import 'package:dwds/src/services/chrome_proxy_service.dart';
1110
import 'package:test/test.dart';
1211
import 'package:test_common/logging.dart';
1312
import 'package:vm_service/vm_service.dart';
14-
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
1513

1614
import 'fixtures/context.dart';
17-
18-
class TestSetup {
19-
static final contextUnsound = TestContext.withWeakNullSafety(
20-
packageName: '_testPackage',
21-
webAssetsPath: 'web',
22-
dartEntryFileName: 'main.dart',
23-
htmlEntryFileName: 'index.html',
24-
);
25-
26-
static final contextSound = TestContext.withSoundNullSafety(
27-
packageName: '_testPackageSound',
28-
webAssetsPath: 'web',
29-
dartEntryFileName: 'main.dart',
30-
htmlEntryFileName: 'index.html',
31-
);
32-
33-
TestContext context;
34-
35-
TestSetup.sound() : context = contextSound;
36-
37-
TestSetup.unsound() : context = contextUnsound;
38-
39-
ChromeProxyService get service =>
40-
fetchChromeProxyService(context.debugConnection);
41-
WipConnection get tabConnection => context.tabConnection;
42-
}
15+
import 'fixtures/project.dart';
4316

4417
void main() {
4518
group(
@@ -50,10 +23,8 @@ void main() {
5023

5124
for (var nullSafety in NullSafety.values) {
5225
group('${nullSafety.name} null safety |', () {
53-
final soundNullSafety = nullSafety == NullSafety.sound;
54-
final setup =
55-
soundNullSafety ? TestSetup.sound() : TestSetup.unsound();
56-
final context = setup.context;
26+
final project = TestProject.testPackage(nullSafety: nullSafety);
27+
final context = TestContext(project);
5728

5829
setUpAll(() async {
5930
setCurrentLogWriter(debug: debug);
@@ -79,17 +50,15 @@ void main() {
7950

8051
setUp(() async {
8152
setCurrentLogWriter(debug: debug);
82-
service = setup.service;
53+
service = context.service;
8354
vm = await service.getVM();
8455
isolate = await service.getIsolate(vm.isolates!.first.id!);
8556
scripts = await service.getScripts(isolate.id!);
8657

8758
await service.streamListen('Debug');
8859
stream = service.onEvent('Debug');
8960

90-
final testPackage =
91-
soundNullSafety ? '_test_package_sound' : '_test_package';
92-
61+
final testPackage = project.packageName;
9362
mainScript = scripts.scripts!
9463
.firstWhere((each) => each.uri!.contains('main.dart'));
9564
testLibraryScript = scripts.scripts!.firstWhere((each) =>
@@ -108,8 +77,8 @@ void main() {
10877
final script = breakpoint.script;
10978
final line =
11079
await context.findBreakpointLine(bpId, isolate.id!, script);
111-
bp = await setup.service
112-
.addBreakpointWithScriptUri(isolate.id!, script.uri!, line);
80+
bp = await service.addBreakpointWithScriptUri(
81+
isolate.id!, script.uri!, line);
11382

11483
expect(bp, isNotNull);
11584
expect(bp.location, _matchBpLocation(script, line, 0));
@@ -121,7 +90,7 @@ void main() {
12190
} finally {
12291
// Remove breakpoint so it doesn't impact other tests or retries.
12392
if (bp != null) {
124-
await setup.service.removeBreakpoint(isolate.id!, bp.id!);
93+
await service.removeBreakpoint(isolate.id!, bp.id!);
12594
}
12695
}
12796
}

dwds/test/build_daemon_circular_evaluate_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:test/test.dart';
99

1010
import 'evaluate_circular_common.dart';
1111
import 'fixtures/context.dart';
12+
import 'fixtures/project.dart';
1213

1314
void main() async {
1415
// Enable verbose logging for debugging.

dwds/test/build_daemon_evaluate_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:test/test.dart';
99

1010
import 'evaluate_common.dart';
1111
import 'fixtures/context.dart';
12+
import 'fixtures/project.dart';
1213

1314
void main() async {
1415
// Enable verbose logging for debugging.

dwds/test/chrome_proxy_service_test.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ import 'package:vm_service/vm_service.dart';
2121
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
2222

2323
import 'fixtures/context.dart';
24+
import 'fixtures/project.dart';
2425

25-
final context = TestContext.withSoundNullSafety();
26-
27-
ChromeProxyService get service =>
28-
fetchChromeProxyService(context.debugConnection);
26+
final context = TestContext(TestProject.testWithSoundNullSafety);
2927

28+
ChromeProxyService get service => context.service;
3029
WipConnection get tabConnection => context.tabConnection;
3130

3231
void main() {

dwds/test/dart_uri_file_uri_test.dart

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,18 @@ import 'package:path/path.dart' as p;
1010
import 'package:test/test.dart';
1111

1212
import 'fixtures/context.dart';
13-
import 'fixtures/utilities.dart';
13+
import 'fixtures/project.dart';
1414

15-
final context = TestContext.withSoundNullSafety(
16-
packageName: '_testPackageSound',
17-
webAssetsPath: 'web',
18-
dartEntryFileName: 'main.dart',
19-
htmlEntryFileName: 'index.html',
20-
);
15+
final testProject = TestProject.testWithSoundNullSafety;
16+
final testPackageProject = TestProject.testPackageWithSoundNullSafety();
17+
final context = TestContext(testPackageProject);
2118

2219
/// The directory for the general _test package.
23-
final testDir = absolutePath(pathFromFixtures: p.join('_testSound'));
20+
final testDir = testProject.absolutePackageDirectory;
2421

2522
/// The directory for the _testPackage package (contained within dwds), which
2623
/// imports _test.
27-
final testPackageDir =
28-
absolutePath(pathFromFixtures: p.join('_testPackageSound'));
24+
final testPackageDir = testPackageProject.absolutePackageDirectory;
2925

3026
// This tests converting file Uris into our internal paths.
3127
//
@@ -41,17 +37,17 @@ void main() {
4137
? 'web/main.dart'
4238
: 'main.dart';
4339

44-
final serverPath =
45-
compilationMode == CompilationMode.frontendServer &&
46-
useDebuggerModuleNames
47-
? 'packages/_testPackageSound/lib/test_library.dart'
48-
: 'packages/_test_package_sound/test_library.dart';
40+
final serverPath = compilationMode ==
41+
CompilationMode.frontendServer &&
42+
useDebuggerModuleNames
43+
? 'packages/${testPackageProject.packageDirectory}/lib/test_library.dart'
44+
: 'packages/${testPackageProject.packageName}/test_library.dart';
4945

5046
final anotherServerPath =
5147
compilationMode == CompilationMode.frontendServer &&
5248
useDebuggerModuleNames
53-
? 'packages/_testSound/lib/library.dart'
54-
: 'packages/_test_sound/library.dart';
49+
? 'packages/${testProject.packageDirectory}/lib/library.dart'
50+
: 'packages/${testProject.packageName}/library.dart';
5551

5652
setUpAll(() async {
5753
await context.setUp(

dwds/test/debug_extension_test.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import 'package:test/test.dart';
1818
import 'package:webdriver/io.dart';
1919

2020
import 'fixtures/context.dart';
21+
import 'fixtures/project.dart';
2122
import 'fixtures/utilities.dart';
2223

2324
// Instructions for running:
@@ -30,7 +31,7 @@ import 'fixtures/utilities.dart';
3031
// Remove the key before pushing code to GitHub.
3132
// See go/extension-identification.
3233

33-
final context = TestContext.withSoundNullSafety();
34+
final context = TestContext(TestProject.testWithSoundNullSafety);
3435

3536
void main() async {
3637
Future<void> waitForDartDevToolsWithRetry({
@@ -204,7 +205,7 @@ void main() async {
204205
}
205206

206207
group('With encoding', () {
207-
final context = TestContext.withSoundNullSafety();
208+
final context = TestContext(TestProject.testWithSoundNullSafety);
208209
setUp(() async {
209210
await context.setUp(
210211
enableDebugExtension: true,
@@ -225,7 +226,7 @@ void main() async {
225226
});
226227

227228
group('With "any" hostname', () {
228-
final context = TestContext.withSoundNullSafety();
229+
final context = TestContext(TestProject.testWithSoundNullSafety);
229230
final uriPattern = RegExp(r'dartExtensionUri = "([^"]+)";');
230231

231232
setUp(() async {

dwds/test/debug_service_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import 'dart:io';
1111
import 'package:test/test.dart';
1212

1313
import 'fixtures/context.dart';
14+
import 'fixtures/project.dart';
1415

15-
final context = TestContext.withSoundNullSafety();
16+
final context = TestContext(TestProject.testWithSoundNullSafety);
1617

1718
void main() {
1819
setUpAll(() async {

dwds/test/debugger_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'
2121
import 'fixtures/context.dart';
2222
import 'fixtures/debugger_data.dart';
2323
import 'fixtures/fakes.dart';
24+
import 'fixtures/project.dart';
2425

25-
final context = TestContext.withSoundNullSafety();
26+
final context = TestContext(TestProject.testWithSoundNullSafety);
2627
late AppInspector inspector;
2728
late Debugger debugger;
2829
late FakeWebkitDebugger webkitDebugger;

dwds/test/devtools_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import 'package:vm_service/vm_service.dart';
1212
import 'package:webdriver/io.dart';
1313

1414
import 'fixtures/context.dart';
15+
import 'fixtures/project.dart';
1516

16-
final context = TestContext.withSoundNullSafety();
17+
final context = TestContext(TestProject.testWithSoundNullSafety);
1718

1819
Future<void> _waitForPageReady(TestContext context) async {
1920
var attempt = 100;

0 commit comments

Comments
 (0)