Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Add more package:test (removing usages of package:litetest) #54882

Merged
merged 8 commits into from
Sep 4, 2024
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
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ workspace:
- testing/benchmark
- testing/dart
- testing/litetest
- testing/pkg_test_demo
- testing/scenario_app
- testing/skia_gold_client
- testing/smoke_test_failure
Expand Down Expand Up @@ -263,6 +262,8 @@ dependency_overrides:
path: ./third_party/dart/third_party/pkg/shelf/pkgs/shelf_static
shelf_web_socket:
path: ./third_party/dart/third_party/pkg/shelf/pkgs/shelf_web_socket
sky_engine:
path: ./sky/packages/sky_engine
smith:
path: ./third_party/dart/pkg/smith
source_map_stack_trace:
Expand Down
32 changes: 0 additions & 32 deletions testing/pkg_test_demo/README.md

This file was deleted.

16 changes: 0 additions & 16 deletions testing/pkg_test_demo/pubspec.yaml

This file was deleted.

17 changes: 0 additions & 17 deletions testing/pkg_test_demo/test/example_test.dart

This file was deleted.

13 changes: 8 additions & 5 deletions testing/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def run_cmd( # pylint: disable=too-many-arguments
allowed_failure = True

if not allowed_failure:
raise RuntimeError('Command "%s" exited with code %s.' % (command_string, process.returncode))
raise RuntimeError(
'Command "%s" (in %s) exited with code %s.' % (command_string, cwd, process.returncode)
)

for forbidden_string in forbidden_output:
if forbidden_string in output:
Expand All @@ -133,7 +135,10 @@ def run_cmd( # pylint: disable=too-many-arguments
)

print_divider('<')
logger.info('Command run successfully in %.2f seconds: %s', end_time - start_time, command_string)
logger.info(
'Command run successfully in %.2f seconds: %s (in %s)', end_time - start_time, command_string,
cwd
)


def is_mac():
Expand Down Expand Up @@ -919,8 +924,7 @@ def gather_dart_package_tests(build_dir, package_path, extra_opts):
#
# Until then, assert that no extra_opts are passed and explain the limitation.
assert not extra_opts, '%s uses package:test and cannot use CLI args' % package_path
# TODO(https://github.com/flutter/flutter/issues/154263): Restore `--disable-dart-dev`.
opts = ['test']
opts = ['test', '--reporter=expanded']
yield EngineExecutableTask(
build_dir, os.path.join('dart-sdk', 'bin', 'dart'), None, flags=opts, cwd=package_path
)
Expand Down Expand Up @@ -976,7 +980,6 @@ def build_dart_host_test_list(build_dir):
],
),
(os.path.join('flutter', 'testing', 'litetest'), []),
(os.path.join('flutter', 'testing', 'pkg_test_demo'), []),
(os.path.join('flutter', 'testing', 'skia_gold_client'), []),
(os.path.join('flutter', 'testing', 'scenario_app'), []),
(
Expand Down
7 changes: 1 addition & 6 deletions testing/scenario_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,4 @@ dependencies:
sky_engine: any

dev_dependencies:
litetest: any

# TODO(matanlurey): Figure out how sky_engine fits into the pub workspace model.
dependency_overrides:
sky_engine:
path: ../../sky/packages/sky_engine
test: any
2 changes: 1 addition & 1 deletion testing/scenario_app/test/adb_log_filter_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

import '../bin/utils/adb_logcat_filtering.dart';
import 'src/fake_adb_logcat.dart';
Expand Down
4 changes: 0 additions & 4 deletions testing/skia_gold_client/lib/skia_gold_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,6 @@ interface class SkiaGoldClient {

/// The path to the local [Directory] where the `goldctl` tool is hosted.
String get _goldctl {
assert(
isAvailable(environment: _environment),
'Trying to use `goldctl` in an environment where it is not available',
);
final String? result = _environment[_kGoldctlKey];
if (result == null || result.isEmpty) {
throw StateError('The environment variable $_kGoldctlKey is not set.');
Expand Down
2 changes: 1 addition & 1 deletion testing/skia_gold_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ dependencies:
process: any

dev_dependencies:
litetest: any
process_fakes: any
test: any
2 changes: 1 addition & 1 deletion testing/skia_gold_client/test/release_version_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:litetest/litetest.dart';
import 'package:skia_gold_client/src/release_version.dart';
import 'package:test/test.dart';

void main() {
test('should accept a major and minor version', () {
Expand Down
2 changes: 1 addition & 1 deletion testing/skia_gold_client/test/skia_gold_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import 'dart:io' as io;
import 'dart:typed_data';

import 'package:engine_repo_tools/engine_repo_tools.dart';
import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as p;
import 'package:process_fakes/process_fakes.dart';
import 'package:skia_gold_client/skia_gold_client.dart';
import 'package:skia_gold_client/src/release_version.dart';
import 'package:test/test.dart';

void main() {
/// A mock commit hash that is used to simulate a successful git call.
Expand Down
2 changes: 1 addition & 1 deletion testing/smoke_test_failure/fail_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:litetest/litetest.dart';
import 'package:test/test.dart';

void main() {
test('test smoke test -- this test SHOULD FAIL', () {
Expand Down
2 changes: 1 addition & 1 deletion testing/smoke_test_failure/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ environment:
resolution: workspace

dependencies:
litetest: any
test: any
2 changes: 1 addition & 1 deletion tools/clang_tidy/lib/src/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:path/path.dart' as path;

import 'lint_target.dart';

final Engine _engineRoot = Engine.findWithin(path.dirname(path.fromUri(io.Platform.script)));
final Engine _engineRoot = Engine.findWithin();

/// Adds warnings as errors for only specific runs. This is helpful if migrating one platform at a time.
String? _platformSpecificWarningsAsErrors(ArgResults options) {
Expand Down
5 changes: 1 addition & 4 deletions tools/clang_tidy/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ dependencies:
process_runner: any

dev_dependencies:
async_helper: any
expect: any
litetest: any
process_fakes: any
smith: any
test: any
yaml: any
51 changes: 32 additions & 19 deletions tools/clang_tidy/test/clang_tidy_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import 'package:clang_tidy/src/command.dart';
import 'package:clang_tidy/src/lint_target.dart';
import 'package:clang_tidy/src/options.dart';
import 'package:engine_repo_tools/engine_repo_tools.dart';
import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as path;
import 'package:process/process.dart';
import 'package:process_fakes/process_fakes.dart';
import 'package:process_runner/process_runner.dart';

import 'package:test/test.dart';

/// A test fixture for the `clang-tidy` tool.
final class Fixture {
Expand Down Expand Up @@ -94,8 +93,7 @@ Use -header-filter=.* to display errors from all non-system headers. Use -system
1 warning treated as error''';

void _withTempFile(String prefix, void Function(String path) func) {
final String filePath =
path.join(io.Directory.systemTemp.path, '$prefix-temp-file');
final String filePath = path.join(io.Directory.systemTemp.path, '$prefix-temp-file');
final io.File file = io.File(filePath);
file.createSync();
try {
Expand All @@ -105,16 +103,27 @@ void _withTempFile(String prefix, void Function(String path) func) {
}
}

Future<int> main(List<String> args) async {
final String? buildCommands =
args.firstOrNull ??
Engine.findWithin().latestOutput()?.compileCommandsJson.path;

if (buildCommands == null || args.length > 1) {
io.stderr.writeln(
'Usage: clang_tidy_test.dart [path/to/compile_commands.json]',
);
return 1;
final _engineRoot = Engine.findWithin();

void main() {
// This test requires a compile_commands.json file to exist.
//
// We can provide exactly which build to use, i.e.:
// COMPILE_COMMANDS_PATH=/path/to/compile_commands.json dart test
//
// Or, we can fall back to the latest build output if one isn't provided.
final String buildCommands;
if (io.Platform.environment['COMPILE_COMMANDS_PATH'] case final String compileCommandsPath) {
buildCommands = compileCommandsPath;
} else {
final String? inferredPath = _engineRoot.latestOutput()?.compileCommandsJson.path;
io.stderr.writeln('No COMPILE_COMMANDS_PATH found in environment.');
if (inferredPath != null) {
io.stderr.writeln('Inferring the last build output: $inferredPath');
buildCommands = inferredPath;
} else {
fail('No outputs or build commands found.');
}
}

test('--help gives help, and uses host_debug by default outside of an engine root', () async {
Expand Down Expand Up @@ -253,7 +262,7 @@ Future<int> main(List<String> args) async {
final int result = await fixture.tool.run();

expect(result, equals(1));
expect(fixture.errBuffer.toString().split('\n')[0], hasMatch(
expect(fixture.errBuffer.toString().split('\n')[0], matches(
r"ERROR: Build commands path .*/does/not/exist doesn't exist.",
));
});
Expand All @@ -270,7 +279,7 @@ Future<int> main(List<String> args) async {
final int result = await fixture.tool.run();

expect(result, equals(1));
expect(fixture.errBuffer.toString().split('\n')[0], hasMatch(
expect(fixture.errBuffer.toString().split('\n')[0], matches(
r'ERROR: Build commands path .*/does/not/exist'
r'[/\\]out[/\\]ios_debug_unopt[/\\]compile_commands.json'
r" doesn't exist.",
Expand Down Expand Up @@ -475,7 +484,13 @@ Future<int> main(List<String> args) async {
);

// This file needs to exist, and be UTF8 line-parsable.
final String filePath = io.Platform.script.toFilePath();
final String filePath = path.join(
_engineRoot.flutterDir.path,
'tools',
'clang_tidy',
'test',
'clang_tidy_test.dart',
);
final List<dynamic> buildCommandsData = <Map<String, dynamic>>[
<String, dynamic>{
'directory': '/unused',
Expand Down Expand Up @@ -657,6 +672,4 @@ Future<int> main(List<String> args) async {

expect(result, 0);
});

return 0;
}
14 changes: 7 additions & 7 deletions tools/clang_tidy/test/header_filter_regex_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import 'dart:io';

import 'package:engine_repo_tools/engine_repo_tools.dart';
import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'package:yaml/yaml.dart' as yaml;

/// Tests that `HeaderFilterRegex` works as expected in `.clang_tidy`.
void main() {
// Find the root of the repo.
final Engine engine = Engine.findWithin(path.dirname(Platform.script.path));
final Engine engine = Engine.findWithin();

// Find the `.clang_tidy` file and "parse" it (it's YAML).
final yaml.YamlDocument dotClangTidy = yaml.loadYamlDocument(
Expand Down Expand Up @@ -62,11 +62,11 @@ void main() {
// Create a fake file in that path, and assert that it matches the regex.
for (final String rootDir in rootDirs) {
final String file = path.join('..', '..', 'flutter', rootDir, 'foo');
if (!regexValue.hasMatch(file)) {
// This is because reason: ... doesn't work in pkg/litetest.
stderr.writeln('Expected "$file" to be caught by HeaderFilterRegex (${regexValue.pattern}).');
}
expect(regexValue.hasMatch(file), isTrue);
expect(
file,
matches(regexValue),
reason: '$rootDir/foo should be allowed by the regex but was not.',
);
}
});
}
2 changes: 1 addition & 1 deletion tools/golden_tests_harvester/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ dependencies:
skia_gold_client: any

dev_dependencies:
litetest: any
test: any
Loading