Skip to content

Move project definitions into a separate class #1975

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

Merged
merged 12 commits into from
Feb 22, 2023
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
14 changes: 3 additions & 11 deletions dwds/test/build_daemon_breakpoint_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,16 @@
@Timeout(Duration(minutes: 2))
import 'dart:async';

import 'package:dwds/src/connections/debug_connection.dart';
import 'package:dwds/src/services/chrome_proxy_service.dart';
import 'package:test/test.dart';
import 'package:vm_service/vm_service.dart';
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';

import 'fixtures/context.dart';
import 'fixtures/project.dart';

final context = TestContext.withSoundNullSafety(
packageName: '_testPackageSound',
webAssetsPath: 'web',
dartEntryFileName: 'main.dart',
htmlEntryFileName: 'index.html',
);
final context = TestContext(TestProject.testPackageWithSoundNullSafety());

ChromeProxyService get service =>
fetchChromeProxyService(context.debugConnection);
WipConnection get tabConnection => context.tabConnection;
ChromeProxyService get service => context.service;

void main() {
group('shared context', () {
Expand Down
47 changes: 8 additions & 39 deletions dwds/test/build_daemon_callstack_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,13 @@
@Timeout(Duration(minutes: 2))
import 'dart:async';

import 'package:dwds/src/connections/debug_connection.dart';
import 'package:dwds/src/services/chrome_proxy_service.dart';
import 'package:test/test.dart';
import 'package:test_common/logging.dart';
import 'package:vm_service/vm_service.dart';
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';

import 'fixtures/context.dart';

class TestSetup {
static final contextUnsound = TestContext.withWeakNullSafety(
packageName: '_testPackage',
webAssetsPath: 'web',
dartEntryFileName: 'main.dart',
htmlEntryFileName: 'index.html',
);

static final contextSound = TestContext.withSoundNullSafety(
packageName: '_testPackageSound',
webAssetsPath: 'web',
dartEntryFileName: 'main.dart',
htmlEntryFileName: 'index.html',
);

TestContext context;

TestSetup.sound() : context = contextSound;

TestSetup.unsound() : context = contextUnsound;

ChromeProxyService get service =>
fetchChromeProxyService(context.debugConnection);
WipConnection get tabConnection => context.tabConnection;
}
import 'fixtures/project.dart';

void main() {
group(
Expand All @@ -50,10 +23,8 @@ void main() {

for (var nullSafety in NullSafety.values) {
group('${nullSafety.name} null safety |', () {
final soundNullSafety = nullSafety == NullSafety.sound;
final setup =
soundNullSafety ? TestSetup.sound() : TestSetup.unsound();
final context = setup.context;
final project = TestProject.testPackage(nullSafety: nullSafety);
final context = TestContext(project);

setUpAll(() async {
setCurrentLogWriter(debug: debug);
Expand All @@ -79,17 +50,15 @@ void main() {

setUp(() async {
setCurrentLogWriter(debug: debug);
service = setup.service;
service = context.service;
vm = await service.getVM();
isolate = await service.getIsolate(vm.isolates!.first.id!);
scripts = await service.getScripts(isolate.id!);

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

final testPackage =
soundNullSafety ? '_test_package_sound' : '_test_package';

final testPackage = project.packageName;
mainScript = scripts.scripts!
.firstWhere((each) => each.uri!.contains('main.dart'));
testLibraryScript = scripts.scripts!.firstWhere((each) =>
Expand All @@ -108,8 +77,8 @@ void main() {
final script = breakpoint.script;
final line =
await context.findBreakpointLine(bpId, isolate.id!, script);
bp = await setup.service
.addBreakpointWithScriptUri(isolate.id!, script.uri!, line);
bp = await service.addBreakpointWithScriptUri(
isolate.id!, script.uri!, line);

expect(bp, isNotNull);
expect(bp.location, _matchBpLocation(script, line, 0));
Expand All @@ -121,7 +90,7 @@ void main() {
} finally {
// Remove breakpoint so it doesn't impact other tests or retries.
if (bp != null) {
await setup.service.removeBreakpoint(isolate.id!, bp.id!);
await service.removeBreakpoint(isolate.id!, bp.id!);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions dwds/test/build_daemon_circular_evaluate_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:test/test.dart';

import 'evaluate_circular_common.dart';
import 'fixtures/context.dart';
import 'fixtures/project.dart';

void main() async {
// Enable verbose logging for debugging.
Expand Down
1 change: 1 addition & 0 deletions dwds/test/build_daemon_evaluate_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:test/test.dart';

import 'evaluate_common.dart';
import 'fixtures/context.dart';
import 'fixtures/project.dart';

void main() async {
// Enable verbose logging for debugging.
Expand Down
7 changes: 3 additions & 4 deletions dwds/test/chrome_proxy_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ import 'package:vm_service/vm_service.dart';
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';

import 'fixtures/context.dart';
import 'fixtures/project.dart';

final context = TestContext.withSoundNullSafety();

ChromeProxyService get service =>
fetchChromeProxyService(context.debugConnection);
final context = TestContext(TestProject.testWithSoundNullSafety);

ChromeProxyService get service => context.service;
WipConnection get tabConnection => context.tabConnection;

void main() {
Expand Down
30 changes: 13 additions & 17 deletions dwds/test/dart_uri_file_uri_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,18 @@ import 'package:path/path.dart' as p;
import 'package:test/test.dart';

import 'fixtures/context.dart';
import 'fixtures/utilities.dart';
import 'fixtures/project.dart';

final context = TestContext.withSoundNullSafety(
packageName: '_testPackageSound',
webAssetsPath: 'web',
dartEntryFileName: 'main.dart',
htmlEntryFileName: 'index.html',
);
final testProject = TestProject.testWithSoundNullSafety;
final testPackageProject = TestProject.testPackageWithSoundNullSafety();
final context = TestContext(testPackageProject);

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

/// The directory for the _testPackage package (contained within dwds), which
/// imports _test.
final testPackageDir =
absolutePath(pathFromFixtures: p.join('_testPackageSound'));
final testPackageDir = testPackageProject.absolutePackageDirectory;

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

final serverPath =
compilationMode == CompilationMode.frontendServer &&
useDebuggerModuleNames
? 'packages/_testPackageSound/lib/test_library.dart'
: 'packages/_test_package_sound/test_library.dart';
final serverPath = compilationMode ==
CompilationMode.frontendServer &&
useDebuggerModuleNames
? 'packages/${testPackageProject.packageDirectory}/lib/test_library.dart'
: 'packages/${testPackageProject.packageName}/test_library.dart';

final anotherServerPath =
compilationMode == CompilationMode.frontendServer &&
useDebuggerModuleNames
? 'packages/_testSound/lib/library.dart'
: 'packages/_test_sound/library.dart';
? 'packages/${testProject.packageDirectory}/lib/library.dart'
: 'packages/${testProject.packageName}/library.dart';

setUpAll(() async {
await context.setUp(
Expand Down
7 changes: 4 additions & 3 deletions dwds/test/debug_extension_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'package:test/test.dart';
import 'package:webdriver/io.dart';

import 'fixtures/context.dart';
import 'fixtures/project.dart';
import 'fixtures/utilities.dart';

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

final context = TestContext.withSoundNullSafety();
final context = TestContext(TestProject.testWithSoundNullSafety);

void main() async {
Future<void> waitForDartDevToolsWithRetry({
Expand Down Expand Up @@ -204,7 +205,7 @@ void main() async {
}

group('With encoding', () {
final context = TestContext.withSoundNullSafety();
final context = TestContext(TestProject.testWithSoundNullSafety);
setUp(() async {
await context.setUp(
enableDebugExtension: true,
Expand All @@ -225,7 +226,7 @@ void main() async {
});

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

setUp(() async {
Expand Down
3 changes: 2 additions & 1 deletion dwds/test/debug_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import 'dart:io';
import 'package:test/test.dart';

import 'fixtures/context.dart';
import 'fixtures/project.dart';

final context = TestContext.withSoundNullSafety();
final context = TestContext(TestProject.testWithSoundNullSafety);

void main() {
setUpAll(() async {
Expand Down
3 changes: 2 additions & 1 deletion dwds/test/debugger_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'
import 'fixtures/context.dart';
import 'fixtures/debugger_data.dart';
import 'fixtures/fakes.dart';
import 'fixtures/project.dart';

final context = TestContext.withSoundNullSafety();
final context = TestContext(TestProject.testWithSoundNullSafety);
late AppInspector inspector;
late Debugger debugger;
late FakeWebkitDebugger webkitDebugger;
Expand Down
3 changes: 2 additions & 1 deletion dwds/test/devtools_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import 'package:vm_service/vm_service.dart';
import 'package:webdriver/io.dart';

import 'fixtures/context.dart';
import 'fixtures/project.dart';

final context = TestContext.withSoundNullSafety();
final context = TestContext(TestProject.testWithSoundNullSafety);

Future<void> _waitForPageReady(TestContext context) async {
var attempt = 100;
Expand Down
Loading