| // 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:convert' as convert; |
| import 'dart:ffi' as ffi show Abi; |
| import 'dart:io' as io; |
| |
| import 'package:engine_build_configs/engine_build_configs.dart'; |
| import 'package:engine_repo_tools/engine_repo_tools.dart'; |
| import 'package:engine_tool/src/commands/command_runner.dart'; |
| import 'package:engine_tool/src/environment.dart'; |
| import 'package:engine_tool/src/logger.dart'; |
| import 'package:litetest/litetest.dart'; |
| import 'package:platform/platform.dart'; |
| import 'package:process_fakes/process_fakes.dart'; |
| import 'package:process_runner/process_runner.dart'; |
| |
| import 'fixtures.dart' as fixtures; |
| |
| void main() { |
| final Engine engine; |
| try { |
| engine = Engine.findWithin(); |
| } catch (e) { |
| io.stderr.writeln(e); |
| io.exitCode = 1; |
| return; |
| } |
| final BuilderConfig linuxTestConfig = BuilderConfig.fromJson( |
| path: 'ci/builders/linux_test_config.json', |
| map: convert.jsonDecode(fixtures.testConfig('Linux', Platform.linux)) |
| as Map<String, Object?>, |
| ); |
| |
| final BuilderConfig macTestConfig = BuilderConfig.fromJson( |
| path: 'ci/builders/mac_test_config.json', |
| map: convert.jsonDecode(fixtures.testConfig('Mac-12', Platform.macOS)) |
| as Map<String, Object?>, |
| ); |
| |
| final BuilderConfig winTestConfig = BuilderConfig.fromJson( |
| path: 'ci/builders/win_test_config.json', |
| map: convert.jsonDecode(fixtures.testConfig('Windows-11', Platform.windows)) |
| as Map<String, Object?>, |
| ); |
| |
| final Map<String, BuilderConfig> configs = <String, BuilderConfig>{ |
| 'linux_test_config': linuxTestConfig, |
| 'linux_test_config2': linuxTestConfig, |
| 'mac_test_config': macTestConfig, |
| 'win_test_config': winTestConfig, |
| }; |
| |
| (Environment, List<List<String>>) macEnv(Logger logger) { |
| final List<List<String>> runHistory = <List<String>>[]; |
| return ( |
| Environment( |
| abi: ffi.Abi.macosArm64, |
| engine: engine, |
| platform: FakePlatform( |
| operatingSystem: Platform.macOS, |
| resolvedExecutable: io.Platform.resolvedExecutable, |
| pathSeparator: '/'), |
| processRunner: ProcessRunner( |
| processManager: FakeProcessManager(onStart: (List<String> command) { |
| runHistory.add(command); |
| return FakeProcess(); |
| }, onRun: (List<String> command) { |
| // Should not be executed. |
| assert(false); |
| return io.ProcessResult(81, 1, '', ''); |
| })), |
| logger: logger, |
| ), |
| runHistory |
| ); |
| } |
| |
| test('invoked linters', () async { |
| final Logger logger = Logger.test((_) {}); |
| final (Environment env, List<List<String>> runHistory) = macEnv(logger); |
| final ToolCommandRunner runner = ToolCommandRunner( |
| environment: env, |
| configs: configs, |
| ); |
| final int result = await runner.run(<String>['lint']); |
| expect(result, equals(0)); |
| expect(runHistory.length, greaterThanOrEqualTo(4)); |
| expect(runHistory[0].firstOrNull, contains('analyze.sh')); |
| }); |
| } |