Skip to content

Refactor TestContext constructor for clarity #1844

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 32 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1b04001
Another attempt at resolving failing tests
elliette Dec 19, 2022
2ab2211
Merge in changes from other PR
elliette Dec 19, 2022
3afe52e
Refactor context.dart
elliette Dec 19, 2022
f2ef91b
wip
elliette Dec 19, 2022
9aa7be4
refactored TestContext constructors
elliette Dec 20, 2022
d8497c7
Use new TestContext constructors everywhere
elliette Dec 20, 2022
9fd513f
Revert mono_repo changes
elliette Dec 20, 2022
1b9cd49
Add another assert
elliette Dec 20, 2022
4ba6def
Merge in master
elliette Dec 20, 2022
ebca04b
Merge in master
elliette Dec 20, 2022
c829bb6
Use helper function in dart_uri_file_uri_test
elliette Dec 20, 2022
e08ad42
More refactoring
elliette Dec 20, 2022
bdc65aa
Update tests
elliette Dec 20, 2022
1093a49
Restore files changed by running mono_repo generate
elliette Dec 20, 2022
6977a21
Use helper function in package_mapper_uri_test
elliette Dec 20, 2022
7319bd7
Merge in changes from other PR
elliette Dec 20, 2022
e972f32
Merge in changes from other PR
elliette Dec 20, 2022
69f5628
Merge in master
elliette Dec 20, 2022
14d66e0
Update how we compute the DWDS path
elliette Dec 20, 2022
d318198
Small cleanup for dwds path
elliette Dec 20, 2022
47bf019
Update test fixtures absolute path
elliette Dec 20, 2022
92ac0de
Pull in changes from master
elliette Dec 21, 2022
37b35e6
Switch to using pathFromFixtures where relevant
elliette Dec 21, 2022
58a1458
Add some logging to try to understand failures
elliette Dec 22, 2022
3661540
Clean up
elliette Dec 22, 2022
50da8b8
Merge branch 'master' into test-directories
elliette Dec 22, 2022
d9ef0af
Rename scopes_main
elliette Dec 22, 2022
423e09d
Committed in wrong directory
elliette Dec 22, 2022
197f7b9
Another attempt at fixing failing tests
elliette Dec 22, 2022
608386e
resolve conflicts
elliette Dec 22, 2022
f3ced07
Update filePathToServe method
elliette Dec 22, 2022
ed47169
Respond to PR comments
elliette Jan 5, 2023
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
12 changes: 6 additions & 6 deletions dwds/test/build_daemon_breakpoint_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import 'dart:async';

import 'package:dwds/src/connections/debug_connection.dart';
import 'package:dwds/src/services/chrome_proxy_service.dart';
import 'package:path/path.dart' as p;
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';

final context = TestContext(
directory: p.join('..', 'fixtures', '_testPackageSound'),
entry: p.join('..', 'fixtures', '_testPackageSound', 'web', 'main.dart'),
path: 'index.html',
pathToServe: 'web');
final context = TestContext.withSoundNullSafety(
packageName: '_testPackageSound',
webAssetsPath: 'web',
dartEntryFileName: 'main.dart',
htmlEntryFileName: 'index.html',
);

ChromeProxyService get service =>
fetchChromeProxyService(context.debugConnection);
Expand Down
23 changes: 10 additions & 13 deletions dwds/test/build_daemon_callstack_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'dart:async';

import 'package:dwds/src/connections/debug_connection.dart';
import 'package:dwds/src/services/chrome_proxy_service.dart';
import 'package:path/path.dart' as p;
import 'package:test/test.dart';
import 'package:vm_service/vm_service.dart';
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
Expand All @@ -18,20 +17,18 @@ import 'fixtures/logging.dart';
import 'utils/version_compatibility.dart';

class TestSetup {
static final contextUnsound = TestContext(
directory: p.join('..', 'fixtures', '_testPackage'),
entry: p.join('..', 'fixtures', '_testPackage', 'web', 'main.dart'),
path: 'index.html',
pathToServe: 'web',
nullSafety: NullSafety.weak,
static final contextUnsound = TestContext.withWeakNullSafety(
packageName: '_testPackage',
webAssetsPath: 'web',
dartEntryFileName: 'main.dart',
htmlEntryFileName: 'index.html',
);

static final contextSound = TestContext(
directory: p.join('..', 'fixtures', '_testPackageSound'),
entry: p.join('..', 'fixtures', '_testPackageSound', 'web', 'main.dart'),
path: 'index.html',
pathToServe: 'web',
nullSafety: NullSafety.sound,
static final contextSound = TestContext.withSoundNullSafety(
packageName: '_testPackageSound',
webAssetsPath: 'web',
dartEntryFileName: 'main.dart',
htmlEntryFileName: 'index.html',
);

TestContext context;
Expand Down
2 changes: 1 addition & 1 deletion dwds/test/chrome_proxy_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
import 'fixtures/context.dart';
import 'fixtures/logging.dart';

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

ChromeProxyService get service =>
fetchChromeProxyService(context.debugConnection);
Expand Down
16 changes: 7 additions & 9 deletions dwds/test/dart_uri_file_uri_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@ import 'fixtures/context.dart';
import 'fixtures/utilities.dart';
import 'utils/version_compatibility.dart';

final context = TestContext(
directory: p.join('..', 'fixtures', '_testPackage'),
entry: p.join('..', 'fixtures', '_testPackage', 'web', 'main.dart'),
path: 'index.html',
pathToServe: 'web',
nullSafety: NullSafety.weak,
final context = TestContext.withWeakNullSafety(
packageName: '_testPackage',
webAssetsPath: 'web',
dartEntryFileName: 'main.dart',
htmlEntryFileName: 'index.html',
);

/// The directory for the general _test package.
final testDir = absolutePath(pathFromDwds: p.join('..', 'fixtures', '_test'));
final testDir = absolutePath(pathFromFixtures: p.join('_test'));

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

// This tests converting file Uris into our internal paths.
//
Expand Down
6 changes: 3 additions & 3 deletions dwds/test/debug_extension_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import 'fixtures/utilities.dart';
// Remove the key before pushing code to GitHub.
// See go/extension-identification.

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

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

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

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

setUp(() async {
Expand Down
2 changes: 1 addition & 1 deletion dwds/test/debug_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:test/test.dart';

import 'fixtures/context.dart';

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

void main() {
setUpAll(() async {
Expand Down
2 changes: 1 addition & 1 deletion dwds/test/debugger_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import 'fixtures/context.dart';
import 'fixtures/debugger_data.dart';
import 'fixtures/fakes.dart';

final context = TestContext();
final context = TestContext.withSoundNullSafety();
late AppInspector inspector;
late Debugger debugger;
late FakeWebkitDebugger webkitDebugger;
Expand Down
4 changes: 1 addition & 3 deletions dwds/test/devtools_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import 'package:webdriver/io.dart';

import 'fixtures/context.dart';

final context = TestContext(
path: 'append_body/index.html',
);
final context = TestContext.withSoundNullSafety();

Future<void> _waitForPageReady(TestContext context) async {
var attempt = 100;
Expand Down
25 changes: 12 additions & 13 deletions dwds/test/evaluate_circular_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'dart:async';

import 'package:dwds/src/connections/debug_connection.dart';
import 'package:dwds/src/services/chrome_proxy_service.dart';
import 'package:path/path.dart' as p;
import 'package:test/test.dart';
import 'package:vm_service/vm_service.dart';
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
Expand All @@ -17,21 +16,21 @@ import 'fixtures/context.dart';
import 'fixtures/logging.dart';

class TestSetup {
static TestContext createContext(
String index, String packageRoot, NullSafety nullSafety) =>
TestContext(
directory: p.join('..', 'fixtures', packageRoot),
entry: p.join('..', 'fixtures', packageRoot, 'web', 'main.dart'),
path: index,
pathToServe: 'web',
nullSafety: nullSafety,
);

static TestContext contextUnsound(String index) =>
createContext(index, '_testCircular2', NullSafety.weak);
TestContext.withWeakNullSafety(
packageName: '_testCircular2',
webAssetsPath: 'web',
dartEntryFileName: 'main.dart',
htmlEntryFileName: index,
);

static TestContext contextSound(String index) =>
createContext(index, '_testCircular2Sound', NullSafety.sound);
TestContext.withSoundNullSafety(
packageName: '_testCircular2Sound',
webAssetsPath: 'web',
dartEntryFileName: 'main.dart',
htmlEntryFileName: index,
);

TestContext context;

Expand Down
24 changes: 12 additions & 12 deletions dwds/test/evaluate_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'dart:async';

import 'package:dwds/src/connections/debug_connection.dart';
import 'package:dwds/src/services/chrome_proxy_service.dart';
import 'package:path/path.dart' as p;
import 'package:test/test.dart';
import 'package:vm_service/vm_service.dart';
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
Expand All @@ -17,20 +16,21 @@ import 'fixtures/context.dart';
import 'fixtures/logging.dart';

class TestSetup {
static TestContext createContext(
String index, String packageRoot, NullSafety nullSafety) =>
TestContext(
directory: p.join('..', 'fixtures', packageRoot),
entry: p.join('..', 'fixtures', packageRoot, 'web', 'main.dart'),
path: index,
pathToServe: 'web',
nullSafety: nullSafety);

static TestContext contextUnsound(String index) =>
createContext(index, '_testPackage', NullSafety.weak);
TestContext.withWeakNullSafety(
packageName: '_testPackage',
webAssetsPath: 'web',
dartEntryFileName: 'main.dart',
htmlEntryFileName: index,
);

static TestContext contextSound(String index) =>
createContext(index, '_testPackageSound', NullSafety.sound);
TestContext.withSoundNullSafety(
packageName: '_testPackageSound',
webAssetsPath: 'web',
dartEntryFileName: 'main.dart',
htmlEntryFileName: index,
);

TestContext context;

Expand Down
2 changes: 1 addition & 1 deletion dwds/test/events_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ChromeProxyService get service =>

WipConnection get tabConnection => context.tabConnection;

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

void main() {
group('serve requests', () {
Expand Down
Loading