From 9297d718a16b80efad8d89708a4773c3321dd9f8 Mon Sep 17 00:00:00 2001 From: Alexander Markov Date: Thu, 11 Jun 2026 08:08:41 -0700 Subject: [PATCH] Revert "[test_runner] Invoke tests with relative paths." This reverts commit b5294b97538cc8d4f221d1306874dfc259c435bc. Reason for revert: many failures on appjit, reload and fuchsia bots Failure Link: Original change's description: > [test_runner] Invoke tests with relative paths. > > This makes tests more reproducible, and makes it easier to copy commands between workspaces, or between a failing bot and a local workspace. > > Change-Id: Ic8dd10a3540f314a406e5c5b0a23d97032e5d01d > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/508364 > Reviewed-by: Alexander Aprelev > Commit-Queue: Ryan Macnak Change-Id: Id7aa668c0609df65a5f622ae73013a15e7f9200e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/511400 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Reviewed-by: Alexander Aprelev Reviewed-by: Nate Biggs Commit-Queue: Alexander Markov --- pkg/test_runner/lib/src/command_output.dart | 4 +++- .../lib/src/compiler_configuration.dart | 14 ++++++++------ pkg/test_runner/lib/src/configuration.dart | 7 ++++++- pkg/test_runner/lib/src/multitest.dart | 2 +- pkg/test_runner/lib/src/test_file.dart | 2 +- pkg/test_runner/lib/src/test_suite.dart | 14 ++++++++------ pkg/test_runner/lib/src/testing_servers.dart | 2 +- tests/standalone/io/process_non_ascii_test.dart | 1 - tests/standalone/io/regress_7679_test.dart | 1 - 9 files changed, 28 insertions(+), 19 deletions(-) diff --git a/pkg/test_runner/lib/src/command_output.dart b/pkg/test_runner/lib/src/command_output.dart index 0843b4d7a08..7f16e867cb2 100644 --- a/pkg/test_runner/lib/src/command_output.dart +++ b/pkg/test_runner/lib/src/command_output.dart @@ -737,7 +737,9 @@ class AnalysisCommandOutput extends CommandOutput with _StaticErrorOutput { files.sort(); for (var file in files) { - var path = Path(file!).toString(); + var path = Path( + file!, + ).relativeTo(testCase.testFile.path.directoryPath).toString(); output.subsection("unexpected analysis errors in $path"); var errors = errorsByFile[file]!; diff --git a/pkg/test_runner/lib/src/compiler_configuration.dart b/pkg/test_runner/lib/src/compiler_configuration.dart index 59b0ad95be2..c0481c32b4d 100644 --- a/pkg/test_runner/lib/src/compiler_configuration.dart +++ b/pkg/test_runner/lib/src/compiler_configuration.dart @@ -1124,7 +1124,8 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration List arguments, Map environmentOverrides, ) { - var compareIl = 'pkg/vm/tool/compare_il$shellScriptExtension'; + var pkgVmDir = Platform.script.resolve('../../../pkg/vm').toFilePath(); + var compareIl = '$pkgVmDir/tool/compare_il$shellScriptExtension'; var args = [ arguments.firstWhere((arg) => arg.endsWith('_il_test.dart')), @@ -1652,7 +1653,8 @@ abstract mixin class VMKernelCompilerMixin { List arguments, Map environmentOverrides, ) { - var genKernel = 'pkg/vm/tool/gen_kernel$shellScriptExtension'; + var pkgVmDir = Platform.script.resolve('../../../pkg/vm').toFilePath(); + var genKernel = '$pkgVmDir/tool/gen_kernel$shellScriptExtension'; var kernelBinariesFolder = _configuration.buildDirectory; if (_useSdk) { @@ -1682,10 +1684,10 @@ abstract mixin class VMKernelCompilerMixin { name.startsWith('--enable-experiment=') || name.startsWith('--keep-class-names-implementing='), ), - if (isProductMode) '-Ddart.vm.product=true', - if (isAsan) '-Ddart.vm.asan=true', - if (isMsan) '-Ddart.vm.msan=true', - if (isTsan) '-Ddart.vm.tsan=true', + '-Ddart.vm.product=$isProductMode', + '-Ddart.vm.asan=$isAsan', + '-Ddart.vm.msan=$isMsan', + '-Ddart.vm.tsan=$isTsan', if (_enableAsserts || arguments.contains('--enable-asserts') || arguments.contains('--enable_asserts')) diff --git a/pkg/test_runner/lib/src/configuration.dart b/pkg/test_runner/lib/src/configuration.dart index eb1f89e2e30..c014a83325d 100644 --- a/pkg/test_runner/lib/src/configuration.dart +++ b/pkg/test_runner/lib/src/configuration.dart @@ -14,6 +14,7 @@ import 'compiler_configuration.dart'; import 'deflake_info.dart'; import 'feature.dart'; import 'path.dart'; +import 'repository.dart'; import 'runtime_configuration.dart'; import 'testing_servers.dart'; @@ -72,7 +73,11 @@ class TestConfiguration { required this.reproducingArguments, this.fastTestsOnly = false, this.printPassingStdout = false, - }) : packages = packages ?? '.dart_tool/package_config.json'; + }) : packages = + packages ?? + Repository.uri + .resolve('.dart_tool/package_config.json') + .toFilePath(); final Map selectors; final Progress progress; diff --git a/pkg/test_runner/lib/src/multitest.dart b/pkg/test_runner/lib/src/multitest.dart index 25548235910..f01a7a81fa6 100644 --- a/pkg/test_runner/lib/src/multitest.dart +++ b/pkg/test_runner/lib/src/multitest.dart @@ -360,5 +360,5 @@ Path _createMultitestDirectory( .append(_suiteNameFromPath(suiteDir)) .join(relative); TestUtils.mkdirRecursive(Path.workingDirectory, path); - return path; + return Path(File(path.toNativePath()).absolute.path); } diff --git a/pkg/test_runner/lib/src/test_file.dart b/pkg/test_runner/lib/src/test_file.dart index a03c0296eeb..47a4e5a99a0 100644 --- a/pkg/test_runner/lib/src/test_file.dart +++ b/pkg/test_runner/lib/src/test_file.dart @@ -349,7 +349,7 @@ class TestFile extends _TestFileBase { // The analyzer package also uses a similar syntax for expectations, but // we don't want the test_runner to inadvertently think files containing // those are static error tests. - if (!filePath.replaceAll('\\', '/').contains('pkg/analyzer/')) { + if (!filePath.replaceAll('\\', '/').contains('/pkg/analyzer/')) { try { errorExpectations.addAll(_parseExpectations(filePath)); } on FormatException catch (error) { diff --git a/pkg/test_runner/lib/src/test_suite.dart b/pkg/test_runner/lib/src/test_suite.dart index a2ff85cadb3..b5b95889fe9 100644 --- a/pkg/test_runner/lib/src/test_suite.dart +++ b/pkg/test_runner/lib/src/test_suite.dart @@ -246,7 +246,7 @@ abstract class TestSuite { String dirname, Path testPath, ) { - var relative = testPath; + var relative = testPath.relativeTo(Repository.dir); relative = relative.directoryPath.append(relative.filenameWithoutExtension); var testUniqueName = TestUtils.getShortName(relative.toString()); @@ -257,7 +257,7 @@ abstract class TestSuite { TestUtils.mkdirRecursive(Path('.'), generatedTestPath); return File( generatedTestPath.toNativePath(), - ).path.replaceAll('\\', '/'); + ).absolute.path.replaceAll('\\', '/'); } /// Create a directories for generated assets (tests, html files, @@ -393,7 +393,7 @@ class VMTestSuite extends TestSuite { configuration.architecture == Architecture.x64c ? '$buildDir/gen/kernel-service.dart.snapshot' : '$buildDir/gen/kernel_service.dill'; - var dfePath = Path(filename).toNativePath(); + var dfePath = Path(filename).absolute.toNativePath(); final experiments = [...configuration.experiments]; var args = [ ...initialTargetArguments, @@ -619,7 +619,7 @@ class StandardTestSuite extends TestSuite { bool recursive = false, }) : dartDir = Repository.dir, listRecursively = recursive, - suiteDir = suiteDirectory, + suiteDir = Repository.dir.join(suiteDirectory), extraVmOptions = configuration.vmOptions, super(configuration, suiteName, statusFilePaths) { // Initialize _dart2JsBootstrapDependencies. @@ -1097,10 +1097,12 @@ class StandardTestSuite extends TestSuite { } else if (configuration.compiler == Compiler.ddc) { var ddcConfig = configuration.compilerConfiguration as DevCompilerConfiguration; - var nameFromModuleRoot = testFile.path; + var nameFromModuleRoot = testFile.path.relativeTo(Repository.dir); var nameFromModuleRootNoExt = "${nameFromModuleRoot.directoryPath}/$nameNoExt"; - var jsDir = Path(compilationTempDir).toString(); + var jsDir = Path( + compilationTempDir, + ).relativeTo(Repository.dir).toString(); var nativeNonNullAsserts = testFile.ddcOptions.contains( '--native-null-assertions', ); diff --git a/pkg/test_runner/lib/src/testing_servers.dart b/pkg/test_runner/lib/src/testing_servers.dart index 1998b640223..99ab706908d 100644 --- a/pkg/test_runner/lib/src/testing_servers.dart +++ b/pkg/test_runner/lib/src/testing_servers.dart @@ -133,7 +133,7 @@ class TestingServers { int port = 0, int crossOriginPort = 0, }) async { - _packageConfig = await loadPackageConfigUri(Uri.base.resolveUri(_packages)); + _packageConfig = await loadPackageConfigUri(_packages); _server = await _startHttpServer(host, port: port); await _startHttpServer( diff --git a/tests/standalone/io/process_non_ascii_test.dart b/tests/standalone/io/process_non_ascii_test.dart index f77896b62e8..72972a76d4c 100644 --- a/tests/standalone/io/process_non_ascii_test.dart +++ b/tests/standalone/io/process_non_ascii_test.dart @@ -32,7 +32,6 @@ main() { executable, [] ..addAll(Platform.executableArguments) - ..add("--packages=" + Platform.packageConfig!) ..add(script), workingDirectory: nonAsciiDir.path, environment: {'DART_CRASHPAD_HANDLER': ''}, diff --git a/tests/standalone/io/regress_7679_test.dart b/tests/standalone/io/regress_7679_test.dart index 35b961d7533..964336e65b9 100644 --- a/tests/standalone/io/regress_7679_test.dart +++ b/tests/standalone/io/regress_7679_test.dart @@ -41,7 +41,6 @@ main() { executable, [] ..addAll(Platform.executableArguments) - ..add("--packages=" + Platform.packageConfig!) ..add('script.dart'), workingDirectory: temp.path, environment: {'DART_CRASHPAD_HANDLER': ''},