Files
sdk/pkg/dartdev/test/sdk_from_path_test.dart
T
Danny Tuppeny f24d4d1653 [dartdev] Fix some tests to work under 'dart test'
Now that the SDK uses Pub Workspaces, using the test runner is enabled in Dart-Code. However there are some differences when using 'dart test' that caused some of these tests to fail - this change addresses them:

- Don't use Platform.script because it won't be the source Dart filename
- Make any `args` to `main()` optional
- Add calls to `test()` around some regression tests

I still have a few remaining failures locally, but I'm not yet sure if they're related to the test runner and will troubleshoot them separately.

Change-Id: I01efc5517174ae7e8146892bba1d84cc69029fd4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421162
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2025-04-15 07:45:39 -07:00

44 lines
1.3 KiB
Dart

// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:convert';
import 'dart:io';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'utils.dart';
// Regression test for https://github.com/dart-lang/sdk/issues/56080
void main() {
late final Process? process;
tearDown(() {
process?.kill();
});
test('sdk_test.dart passes when run with dart from PATH', () async {
final sdkTestUri = resolveDartDevUri('test/sdk_test.dart');
process = await Process.start(
'dart',
[sdkTestUri.toFilePath()],
environment: {'PATH': path.dirname(Platform.resolvedExecutable)},
);
// All tests in sdk_test.dart should pass when `dart` is invoked from PATH.
final exitCode = await process!.exitCode;
if (exitCode != 0) {
print('EXIT CODE: $exitCode');
print('STDOUT:');
print(await process!.stdout.transform(utf8.decoder).join());
print('');
print('STDERR:');
print(await process!.stderr.transform(utf8.decoder).join());
print('sdk_test.dart failed when run with dart from PATH!');
}
});
}