From 286169bb52d3b38ef6ef44dd441b013422d4cc15 Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Fri, 8 Mar 2024 23:49:32 +0000 Subject: [PATCH] Don't rely on dart binary on PATH in run_test.py (flutter/engine#51302) --- engine/src/flutter/testing/run_tests.py | 6 +++--- .../dir_contents_diff/test/dir_contents_diff_test.dart | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/engine/src/flutter/testing/run_tests.py b/engine/src/flutter/testing/run_tests.py index 44683edc387..5003b372227 100755 --- a/engine/src/flutter/testing/run_tests.py +++ b/engine/src/flutter/testing/run_tests.py @@ -1037,10 +1037,11 @@ def run_impeller_golden_tests(build_dir: str): ).joinpath('golden_tests_harvester') with tempfile.TemporaryDirectory(prefix='impeller_golden') as temp_dir: run_cmd([tests_path, f'--working_dir={temp_dir}'], cwd=build_dir) + dart_bin = os.path.join(build_dir, 'dart-sdk', 'bin', 'dart') golden_path = os.path.join('testing', 'impeller_golden_tests_output.txt') script_path = os.path.join('tools', 'dir_contents_diff', 'bin', 'dir_contents_diff.dart') diff_result = subprocess.run( - f'dart run {script_path} {golden_path} {temp_dir}', + f'{dart_bin} run {script_path} {golden_path} {temp_dir}', check=False, shell=True, stdout=subprocess.PIPE, @@ -1052,9 +1053,8 @@ def run_impeller_golden_tests(build_dir: str): raise RuntimeError('impeller_golden_tests diff failure') with DirectoryChange(harvester_path): - run_cmd(['dart', 'pub', 'get']) bin_path = Path('.').joinpath('bin').joinpath('golden_tests_harvester.dart') - run_cmd(['dart', 'run', str(bin_path), temp_dir]) + run_cmd([dart_bin, 'run', str(bin_path), temp_dir]) def main(): diff --git a/engine/src/flutter/tools/dir_contents_diff/test/dir_contents_diff_test.dart b/engine/src/flutter/tools/dir_contents_diff/test/dir_contents_diff_test.dart index 4bfa559c511..d2ed1c51aef 100644 --- a/engine/src/flutter/tools/dir_contents_diff/test/dir_contents_diff_test.dart +++ b/engine/src/flutter/tools/dir_contents_diff/test/dir_contents_diff_test.dart @@ -1,3 +1,7 @@ +// Copyright 2013 The Flutter Authors. 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:io' as io; import 'package:litetest/litetest.dart'; @@ -19,11 +23,10 @@ void main() { return; } - // Runs `../bin/dir_contents_diff.dart` with the given arguments. (int, String) runSync(String goldenPath, String dirPath) { final io.ProcessResult result = io.Process.runSync( - 'dart', + io.Platform.resolvedExecutable, [binPath, goldenPath, dirPath], ); return (result.exitCode, result.stdout ?? result.stderr);