Skip to content
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
836 changes: 669 additions & 167 deletions .github/workflows/dart.yml

Large diffs are not rendered by default.

41 changes: 38 additions & 3 deletions dwds/mono_pkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,52 @@ stages:
- test: test/build/min_sdk_test.dart --run-skipped
sdk: stable
- unit_test:
# Linux extension tests:
# Note: `Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &` must be
# run first for Linux.
- group:
- command: Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
- test:
- test: --tags=extension
sdk:
- dev
- stable
- test:
os: windows
os:
- linux
# Windows extension tests:
- group:
- test: --tags=extension
sdk:
- dev
- stable
os:
- windows
# First test shard:
- group:
- test: --total-shards 3 --shard-index 0 --exclude-tags=extension
sdk:
- dev
- stable
os:
- linux
- windows
# Second test shard:
- group:
- test: --total-shards 3 --shard-index 1 --exclude-tags=extension
sdk:
- dev
- stable
os:
- linux
- windows
# Third test shard:
- group:
- test: --total-shards 3 --shard-index 2 --exclude-tags=extension
sdk:
- dev
- stable
os:
- linux
- windows
- beta_cron:
- analyze: .
sdk: beta
Expand Down
12 changes: 4 additions & 8 deletions dwds/test/dart_uri_file_uri_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// BSD-style license that can be found in the LICENSE file.

@TestOn('vm')
import 'dart:io';

import 'package:dwds/src/utilities/dart_uri.dart';
import 'package:path/path.dart' as p;
import 'package:test/test.dart';

import 'fixtures/context.dart';
import 'fixtures/utilities.dart';
import 'utils/version_compatibility.dart';

final context = TestContext(
Expand All @@ -20,17 +20,13 @@ final context = TestContext(
nullSafety: NullSafety.weak,
);

final dwdsDir = Directory.current.absolute.path;

/// The directory for the general _test package.
final testDir = p.normalize(p.absolute(p.relative(
p.join('..', 'fixtures', '_test'),
from: p.current,
)));
final testDir = absolutePath(pathFromDwds: p.join('..', 'fixtures', '_test'));

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

// This tests converting file Uris into our internal paths.
//
Expand Down
32 changes: 6 additions & 26 deletions dwds/test/fixtures/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ class TestContext {

NullSafety nullSafety;

late String dwdsDirectory;

TestContext({
String? directory,
String? entry,
Expand All @@ -124,18 +122,15 @@ class TestContext {
this.pathToServe = 'example',
}) {
final pathParts = p.split(p.current);
assert(pathParts.contains('dwds'));
dwdsDirectory = p.joinAll(
pathParts.sublist(0, pathParts.indexOf('dwds') + 1),
);
assert(pathParts.contains('webdev'));
final defaultPackage =
nullSafety == NullSafety.sound ? '_testSound' : '_test';
final defaultDirectory = p.join('..', 'fixtures', defaultPackage);
final defaultEntry = p.join('..', 'fixtures', defaultPackage, 'example',
'append_body', 'main.dart');

workingDirectory = p.normalize(p.absolute(
p.relative(directory ?? defaultDirectory, from: dwdsDirectory)));
workingDirectory =
absolutePath(pathFromDwds: directory ?? defaultDirectory);

DartUri.currentDirectory = workingDirectory;

Expand All @@ -144,8 +139,7 @@ class TestContext {
_packageConfigFile =
p.toUri(p.join(workingDirectory, '.dart_tool/package_config.json'));

final entryFilePath = p.normalize(
p.absolute(p.relative(entry ?? defaultEntry, from: dwdsDirectory)));
final entryFilePath = absolutePath(pathFromDwds: entry ?? defaultEntry);

_logger.info('Serving: $pathToServe/$path');
_logger.info('Project: $_projectDirectory');
Expand Down Expand Up @@ -430,12 +424,6 @@ class TestContext {
}
}

String absoluteDwdsPath(String relativePath) =>
p.normalize(p.absolute(p.relative(
relativePath,
from: dwdsDirectory,
)));

Future<void> startDebugging() async {
debugConnection = await testServer.dwds.debugConnection(appConnection);
_webkitDebugger = WebkitDebugger(WipDebugger(tabConnection));
Expand Down Expand Up @@ -482,16 +470,8 @@ class TestContext {
}

Future<void> _buildDebugExtension() async {
final currentDir = Directory.current.path;
if (!currentDir.endsWith('dwds')) {
throw StateError(
'Expected to be in /dwds directory, instead path was $currentDir.');
}
final process = await Process.run(
'tool/build_extension.sh',
['prod'],
workingDirectory: '$currentDir/debug_extension',
);
final process = await Process.run('tool/build_extension.sh', ['prod'],
workingDirectory: absolutePath(pathFromDwds: 'debug_extension'));
print(process.stdout);
}

Expand Down
23 changes: 23 additions & 0 deletions dwds/test/fixtures/utilities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@ import 'package:build_daemon/constants.dart';
import 'package:build_daemon/data/server_log.dart';
import 'package:path/path.dart' as p;

const webdevDirName = 'webdev';
const dwdsDirName = 'dwds';

/// The path to the DWDS directory in the local machine, e.g.
/// "/workstation/webdev/dwds".
String get dwdsPath {
final pathParts = p.split(p.current);
// We expect all tests to be run from the webdev mono-repo:
assert(pathParts.contains(webdevDirName));
return p.joinAll(
[
...pathParts.sublist(0, pathParts.lastIndexOf(webdevDirName) + 1),
dwdsDirName,
],
);
}

/// Given a [pathFromDwds], e.g. '../fixtures/_test', returns its absolute
/// path, e.g. '/workstation/webdev/fixtures/_test'.
String absolutePath({required String pathFromDwds}) => p.normalize(
p.join(dwdsPath, pathFromDwds),
);

/// Connects to the `build_runner` daemon.
Future<BuildDaemonClient> connectClient(String workingDirectory,
List<String> options, Function(ServerLog) logHandler) =>
Expand Down
7 changes: 3 additions & 4 deletions dwds/test/package_uri_mapper_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import 'package:file/local.dart';
import 'package:path/path.dart' as p;
import 'package:test/test.dart';

import 'fixtures/context.dart';

final testContext = TestContext();
import 'fixtures/utilities.dart';

void main() {
for (final useDebuggerModuleNames in [true, false]) {
Expand All @@ -32,7 +30,8 @@ void main() {
final resolvedPath =
'/webdev/fixtures/_testPackageSound/lib/test_library.dart';

final testPackageSoundPath = testContext.absoluteDwdsPath(p.join(
final testPackageSoundPath = absolutePath(
pathFromDwds: p.join(
'..',
'fixtures',
'_testPackageSound',
Expand Down
11 changes: 7 additions & 4 deletions dwds/test/readers/frontend_server_asset_reader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import '../fixtures/context.dart';
import '../fixtures/utilities.dart';
import '../utils/version_compatibility.dart';

final packagesDir = p.relative('../fixtures/_test', from: p.current);
final packagesDir = absolutePath(
pathFromDwds: p.join('..', 'fixtures', '_test'),
);

final fixturesDir = absolutePath(pathFromDwds: p.join('test', 'fixtures'));

void main() {
late FrontendServerAssetReader assetReader;
Expand All @@ -22,12 +26,11 @@ void main() {
late File mapOriginal;

Future<void> createTempFixtures() async {
final fixtures = p.join('test', 'fixtures');
tempFixtures = await Directory.systemTemp.createTemp('dwds_test_fixtures');
await tempFixtures.create();
jsonOriginal = await File(p.join(fixtures, 'main.dart.dill.json'))
jsonOriginal = await File(p.join(fixturesDir, 'main.dart.dill.json'))
.copy(p.join(tempFixtures.path, 'main.dart.dill.json'));
mapOriginal = await File(p.join(fixtures, 'main.dart.dill.map'))
mapOriginal = await File(p.join(fixturesDir, 'main.dart.dill.map'))
.copy(p.join(tempFixtures.path, 'main.dart.dill.map'));
}

Expand Down
20 changes: 16 additions & 4 deletions tool/ci.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.