From 02cd80ed67c2d8949811d4f57e1ef32655985029 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 13:15:14 -0400 Subject: [PATCH 01/28] Cherry pick from feature/fvm-skip-input-support --- bin/commands.dart | 42 +++++++----------------- bin/link.dart | 20 ++++++----- bin/projects.dart | 12 +++---- bin/puby.dart | 24 +++++++------- lib/engine.dart | 2 +- lib/pens.dart | 13 -------- pubspec.yaml | 4 +-- test/fvm_version_not_installed_test.dart | 5 +-- test/pub_test.dart | 5 --- test/test_utils.dart | 25 ++++++++++++-- 10 files changed, 72 insertions(+), 80 deletions(-) delete mode 100644 lib/pens.dart diff --git a/bin/commands.dart b/bin/commands.dart index f6042d8..62d27af 100644 --- a/bin/commands.dart +++ b/bin/commands.dart @@ -1,9 +1,8 @@ -import 'dart:convert'; import 'dart:io'; +import 'package:io/io.dart'; import 'package:puby/command.dart'; -import 'package:puby/engine.dart'; -import 'package:puby/pens.dart'; +import 'package:io/ansi.dart'; import 'package:puby/project.dart'; import 'package:puby/time.dart'; @@ -87,15 +86,16 @@ extension ProjectCommandExtension on ProjectCommand { if (resolved.exclude) return 0; final finalArgs = [ - if (!raw) ...resolved.engine.args, + if (!raw) ...resolved.engine.prefixArgs, ...args, + if (!raw) ...resolved.engine.suffixArgs, ]; final argString = finalArgs.join(' '); final pathString = resolved.path == '.' ? 'current directory' : resolved.path; if (!silent) { - print(greenPen('Running "$argString" in $pathString...')); + print(green.wrap('Running "$argString" in $pathString...')); } final process = await Process.start( @@ -140,38 +140,20 @@ extension ProjectCommandExtension on ProjectCommand { } stopwatch.stop(); + // Skip error handling if the command was successful or this is a raw command - if (raw || processExitCode == 0) { + if (raw || exitCode == 0) { print( - greenPen( + green.wrap( 'Ran "$argString" in $pathString (${stopwatch.prettyPrint()})', ), ); - - return processExitCode; - } - - if (err.any( - (e) => e.contains( - 'Flutter users should run `flutter pub get` instead of `dart pub get`.', - ), - )) { - // If a project doesn't explicitly depend on flutter, it is not possible - // to know if it's dependencies require flutter. So retry if that's the - // reason for failure. - print(yellowPen('Retrying with "flutter" engine')); - return runInProject(resolved.copyWith(engine: Engine.flutter)); - } - - final unknownSubcommandMatch = - RegExp(r'Could not find a subcommand named "(.+?)" for ".+? pub"\.') - .firstMatch(err.join('\n')); - if (unknownSubcommandMatch != null) { + } else if (exitCode == ExitCode.usage.code) { // Do not attempt to run in other projects if the command is unknown - print(redPen('Unknown command: ${unknownSubcommandMatch[1]}')); - exit(1); + print(red.wrap('Unknown command. Exiting...')); + exit(exitCode); } - return processExitCode; + return exitCode; } } diff --git a/bin/link.dart b/bin/link.dart index 381bd40..ffaa9f2 100644 --- a/bin/link.dart +++ b/bin/link.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:flutter_tools_task_queue/flutter_tools_task_queue.dart'; import 'package:puby/command.dart'; -import 'package:puby/pens.dart'; +import 'package:io/ansi.dart'; import 'package:puby/project.dart'; import 'package:puby/pub.dart'; import 'package:puby/time.dart'; @@ -26,7 +26,7 @@ Future linkDependencies({ if (resolved.exclude) return; final flutterVersionOverride = - await resolved.getFlutterVersionOverride(command); + resolved.getFlutterVersionOverride(command); final entry = Entrypoint(resolved.path, _pubCache); try { @@ -42,15 +42,17 @@ Future linkDependencies({ dependencies.addAll(result.packages); print('Resolved dependencies for ${resolved.path}'); } catch (e) { - print(redPen('Failed to resolve dependencies for ${resolved.path}')); - print(redPen(e)); + print( + red.wrap('Failed to resolve dependencies for ${resolved.path}'), + ); + print(red.wrap(e.toString())); } }), ); } await resolutionQueue.tasksComplete; print( - greenPen( + green.wrap( 'Resolved all dependencies in ${resolutionStopwatch.prettyPrint()}', ), ); @@ -69,16 +71,18 @@ Future linkDependencies({ } } catch (e) { print( - redPen('Failed to download ${package.name} ${package.version}'), + red.wrap('Failed to download ${package.name} ${package.version}'), ); - print(redPen(e)); + print(red.wrap(e.toString())); } }), ); } await downloadQueue.tasksComplete; print( - greenPen('Downloaded all packages in ${downloadStopwatch.prettyPrint()}\n'), + green.wrap( + 'Downloaded all packages in ${downloadStopwatch.prettyPrint()}\n', + ), ); // Stop all stopwatches diff --git a/bin/projects.dart b/bin/projects.dart index 58a2337..189d18c 100644 --- a/bin/projects.dart +++ b/bin/projects.dart @@ -6,7 +6,7 @@ import 'package:pubspec_parse/pubspec_parse.dart'; import 'package:puby/command.dart'; import 'package:puby/config.dart'; import 'package:puby/engine.dart'; -import 'package:puby/pens.dart'; +import 'package:io/ansi.dart'; import 'package:puby/project.dart'; import 'package:path/path.dart' as p; @@ -35,7 +35,7 @@ List findProjects() { try { pubspec = Pubspec.parse(pubspecEntity.readAsStringSync()); } catch (e) { - print(redPen('Error parsing pubspec: $path')); + print(red.wrap('Error parsing pubspec: $path')); pubspec = null; } @@ -91,7 +91,7 @@ extension ProjectExtension on Project { } if (message != null && !command.silent) { - print(yellowPen(message)); + print(yellow.wrap(message)); } return newEngine; } @@ -122,7 +122,7 @@ extension ProjectExtension on Project { } if (message != null && !command.silent) { - print(yellowPen(message)); + print(yellow.wrap(message)); } return skip; } @@ -132,7 +132,7 @@ extension ProjectExtension on Project { final skip = config.excludes.any(argString.startsWith); if (skip && !command.silent) { - print(yellowPen('Skipping project with exclusion: $path')); + print(yellow.wrap('Skipping project with exclusion: $path')); } return skip; @@ -167,7 +167,7 @@ extension ProjectExtension on Project { } return Version.parse(versionString); } catch (e) { - print(redPen('Unable to determine FVM Flutter version: $path')); + print(red.wrap('Unable to determine FVM Flutter version: $path')); return null; } } diff --git a/bin/puby.dart b/bin/puby.dart index 236ab08..59bfd9c 100644 --- a/bin/puby.dart +++ b/bin/puby.dart @@ -2,9 +2,11 @@ import 'dart:async'; import 'dart:io'; import 'package:flutter_tools_task_queue/flutter_tools_task_queue.dart'; +import 'package:io/io.dart'; import 'package:pub_update_checker/pub_update_checker.dart'; import 'package:puby/command.dart'; -import 'package:puby/pens.dart'; +import 'package:puby/engine.dart'; +import 'package:io/ansi.dart'; import 'package:puby/project.dart'; import 'package:puby/time.dart'; @@ -30,7 +32,7 @@ void main(List arguments) async { final newVersion = await PubUpdateChecker.check(); if (newVersion != null) { print( - yellowPen( + yellow.wrap( 'There is an update available: $newVersion. Run `dart pub global activate puby` to update.', ), ); @@ -41,18 +43,18 @@ void main(List arguments) async { arguments.first == '--help'; if (showHelp) { - print(magentaPen(help)); - exit(1); + print(magenta.wrap(help)); + exit(ExitCode.success.code); } print('Finding projects...'); final projects = findProjects(); if (projects.isEmpty) { - print(redPen('No projects found in the current directory')); - exit(1); + print(red.wrap('No projects found in the current directory')); + exit(ExitCode.usage.code); } - print(greenPen('Found ${projects.length} projects\n')); + print(green.wrap('Found ${projects.length} projects\n')); final firstArg = arguments.first; final convenienceCommand = Commands.convenience[firstArg]; @@ -121,13 +123,13 @@ Future runInAllProjects( final time = stopwatch.prettyPrint(); if (exitCode != 0) { - print(redPen('One or more commands failed ($time)')); - print(redPen('Failures:')); + print(red.wrap('One or more commands failed ($time)')); + print(red.wrap('Failures:')); for (final failure in failures) { - print(redPen(' $failure')); + print(red.wrap(' $failure')); } } else { - print(greenPen('All commands succeeded ($time)')); + print(green.wrap('All commands succeeded ($time)')); } print(''); diff --git a/lib/engine.dart b/lib/engine.dart index bebe784..cb956dc 100644 --- a/lib/engine.dart +++ b/lib/engine.dart @@ -13,7 +13,7 @@ enum Engine { bool get isFlutter => {flutter, fvm}.contains(this); /// The arguments required to call the engine - List get args { + List get prefixArgs { switch (this) { case Engine.dart: case Engine.flutter: diff --git a/lib/pens.dart b/lib/pens.dart deleted file mode 100644 index 49720b8..0000000 --- a/lib/pens.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:ansicolor/ansicolor.dart'; - -/// Magenta pen -final magentaPen = AnsiPen()..magenta(); - -/// Green pen -final greenPen = AnsiPen()..green(); - -/// Yellow pen -final yellowPen = AnsiPen()..yellow(); - -/// Red pen -final redPen = AnsiPen()..red(); diff --git a/pubspec.yaml b/pubspec.yaml index 0a4547f..2165848 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,11 +10,11 @@ dependencies: yaml: ^3.1.1 pubspec_parse: ^1.2.1 path: ^1.8.1 - ansicolor: ^2.0.1 pub_update_checker: ^1.2.0 flutter_tools_task_queue: ^1.0.0 - dart_pub: 0.0.1 + dart_pub: 0.0.3 pub_semver: ^2.1.4 + io: ^1.0.4 dev_dependencies: test: ^1.20.2 diff --git a/test/fvm_version_not_installed_test.dart b/test/fvm_version_not_installed_test.dart index 5c8afc8..29032f7 100644 --- a/test/fvm_version_not_installed_test.dart +++ b/test/fvm_version_not_installed_test.dart @@ -1,3 +1,4 @@ +import 'package:io/io.dart'; import 'package:test/test.dart'; import 'test_utils.dart'; @@ -10,7 +11,7 @@ void main() { ); final stdout = result.stdout; - expect(result.exitCode, isNot(0)); - expectLine(stdout, ['Run `fvm install 1.17.0` first']); + expect(result.exitCode, ExitCode.unavailable.code); + expectLine(stdout, ['Flutter SDK: SDK Version : 1.17.0 is not installed.']); }); } diff --git a/test/pub_test.dart b/test/pub_test.dart index 249c8d0..daad207 100644 --- a/test/pub_test.dart +++ b/test/pub_test.dart @@ -40,11 +40,6 @@ void main() { expectLine(stdout, ['invalid_pubspec_test', 'Error parsing pubspec']); // transitive flutter - // This one should fail - // TODO: This isn't failing anymore for some reason. Remove this feature? expectLine(stdout, ['transitive_flutter_test', 'dart pub get']); - - // This one should succeed - // expectLine(stdout, ['transitive_flutter_test', 'flutter pub get']); }); } diff --git a/test/test_utils.dart b/test/test_utils.dart index 45f78e7..3c5d409 100644 --- a/test/test_utils.dart +++ b/test/test_utils.dart @@ -1,18 +1,39 @@ +import 'dart:convert'; import 'dart:io'; import 'package:test/test.dart'; +final _decoder = Utf8Decoder(); + Future testCommand( List arguments, { String workingDirectory = 'test_resources', -}) { + bool debug = false, +}) async { final levels = workingDirectory.split('/').length; final root = '../' * levels; - return Process.run( + final process = await Process.start( 'dart', ['${root}bin/puby.dart', ...arguments], workingDirectory: workingDirectory, ); + + String handleLine(dynamic line) { + final decoded = _decoder.convert(line); + if (debug) stdout.write(decoded); + return decoded; + } + + final processStdout = process.stdout.map(handleLine).join('\n'); + final processStderr = process.stderr.map(handleLine).join('\n'); + + final exitCode = await process.exitCode; + return ProcessResult( + process.pid, + exitCode, + await processStdout, + await processStderr, + ); } void expectLine(dynamic stdout, List matchers, {bool matches = true}) { From 67de2a3c7306a418f6315c53ed9f1a7fe91fe283 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 13:18:11 -0400 Subject: [PATCH 02/28] Add fvm check --- bin/fvm.dart | 33 +++++++++++++++++++++++++++++++++ bin/puby.dart | 5 +++++ 2 files changed, 38 insertions(+) create mode 100644 bin/fvm.dart diff --git a/bin/fvm.dart b/bin/fvm.dart new file mode 100644 index 0000000..a717d49 --- /dev/null +++ b/bin/fvm.dart @@ -0,0 +1,33 @@ +import 'dart:io'; + +import 'package:pub_semver/pub_semver.dart'; +import 'package:io/ansi.dart'; + +final minFvmVersion = Version.parse('3.0.0'); + +void fvmCheck() { + try { + final fvmVersionResult = Process.runSync('fvm', ['--version']); + final fvmVersion = Version.parse(fvmVersionResult.stdout.toString().trim()); + if (fvmVersion < minFvmVersion) { + print( + yellow.wrap( + ''' +This version of puby expects FVM version $minFvmVersion or higher +FVM version $fvmVersion is installed +Commands in projects configured with FVM may fail +''', + ), + ); + } + } catch (e) { + print( + red.wrap( + ''' +FVM is not installed +Commands in projects configured with FVM will fail +''', + ), + ); + } +} diff --git a/bin/puby.dart b/bin/puby.dart index 59bfd9c..7fe9fba 100644 --- a/bin/puby.dart +++ b/bin/puby.dart @@ -12,6 +12,7 @@ import 'package:puby/time.dart'; import 'commands.dart'; import 'projects.dart'; +import 'fvm.dart'; const help = ''' Commands: @@ -56,6 +57,10 @@ void main(List arguments) async { print(green.wrap('Found ${projects.length} projects\n')); + if (projects.any((e) => e.engine == Engine.fvm)) { + fvmCheck(); + } + final firstArg = arguments.first; final convenienceCommand = Commands.convenience[firstArg]; From d0bcc754b3010de109d855fd1817458cad57dd0f Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 13:20:00 -0400 Subject: [PATCH 03/28] Fixes --- bin/commands.dart | 9 +++++---- bin/link.dart | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/commands.dart b/bin/commands.dart index 62d27af..b2cda9e 100644 --- a/bin/commands.dart +++ b/bin/commands.dart @@ -1,8 +1,10 @@ +import 'dart:convert'; import 'dart:io'; import 'package:io/io.dart'; import 'package:puby/command.dart'; import 'package:io/ansi.dart'; +import 'package:puby/engine.dart'; import 'package:puby/project.dart'; import 'package:puby/time.dart'; @@ -64,7 +66,7 @@ abstract class Commands { // hanging if (!command.silent) { print( - redPen( + red.wrap( 'Run `fvm install ${flutterVersionNotInstalledMatch[1]}` first', ), ); @@ -88,7 +90,6 @@ extension ProjectCommandExtension on ProjectCommand { final finalArgs = [ if (!raw) ...resolved.engine.prefixArgs, ...args, - if (!raw) ...resolved.engine.suffixArgs, ]; final argString = finalArgs.join(' '); @@ -124,12 +125,12 @@ extension ProjectCommandExtension on ProjectCommand { .map(_decoder.convert) .listen((line) { if (!silent) { - stderr.write(redPen(line)); + stderr.write(red.wrap(line)); } err.add(line); }).asFuture(); - final processExitCode = await process.exitCode; + final exitCode = await process.exitCode; if (!killed) { // If we do not wait for these streams to finish, output could end up diff --git a/bin/link.dart b/bin/link.dart index ffaa9f2..ec97434 100644 --- a/bin/link.dart +++ b/bin/link.dart @@ -26,7 +26,7 @@ Future linkDependencies({ if (resolved.exclude) return; final flutterVersionOverride = - resolved.getFlutterVersionOverride(command); + await resolved.getFlutterVersionOverride(command); final entry = Entrypoint(resolved.path, _pubCache); try { From b807214c51811ce1a27f12079a85aa1d47c66289 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 13:31:00 -0400 Subject: [PATCH 04/28] Do not run pub get in any example project --- CHANGELOG.md | 6 ++++++ bin/projects.dart | 9 ++++----- pubspec.yaml | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ebadd6..2b41251 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.36.0 + +- Improves exit codes +- Adds safety checks for FVM usage +- Skips `pub get` in all example projects + ## 1.35.0 - `puby link` no longer runs `pub get --offline` in flutter example projects - Fixes `--no-fvm` flag for `puby link` diff --git a/bin/projects.dart b/bin/projects.dart index 189d18c..9f1d7cf 100644 --- a/bin/projects.dart +++ b/bin/projects.dart @@ -97,8 +97,7 @@ extension ProjectExtension on Project { } bool _defaultExclude(Command command) { - final isPubGetInFlutterExample = engine.isFlutter && - example && + final isPubGetInExample = example && command.args.length >= 2 && command.args[0] == 'pub' && command.args[1] == 'get'; @@ -112,9 +111,9 @@ extension ProjectExtension on Project { } else if (path.startsWith('build/') || path.contains('/build/')) { message = 'Skipping project in build folder: $path'; skip = true; - } else if (isPubGetInFlutterExample) { - // Skip flutter pub get in example projects since flutter does it anyways - message = 'Skipping flutter example project: $path'; + } else if (isPubGetInExample) { + // Skip pub get in example projects since it happens anyways + message = 'Skipping example project: $path'; skip = true; } else { message = null; diff --git a/pubspec.yaml b/pubspec.yaml index 2165848..ee514c5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: puby description: Run commands in all projects in the current directory. Handle monorepos with ease. -version: 1.35.0 +version: 1.36.0 homepage: https://github.com/Rexios80/puby environment: From 003bf044f49c08f4b8bdb5fde6ea4e86f0d32606 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 13:32:51 -0400 Subject: [PATCH 05/28] Fixing tests --- test/clean_test.dart | 3 ++- test/exec_test.dart | 3 ++- test/fvm_version_not_installed_test.dart | 4 ++-- test/gen_test.dart | 3 ++- test/link_test.dart | 5 ++++- test/mup_test.dart | 3 ++- test/no_fvm_test.dart | 7 ++++--- test/pub_test.dart | 6 ++++-- test/test_test.dart | 3 ++- test/unknown_command_test.dart | 5 +++-- 10 files changed, 27 insertions(+), 15 deletions(-) diff --git a/test/clean_test.dart b/test/clean_test.dart index 97d5c7e..d9ec358 100644 --- a/test/clean_test.dart +++ b/test/clean_test.dart @@ -1,3 +1,4 @@ +import 'package:io/io.dart'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; @@ -8,7 +9,7 @@ void main() { final result = await testCommand(['clean']); final stdout = result.stdout; - expect(result.exitCode, 0); + expect(result.exitCode, ExitCode.success.code); // dart expectLine(stdout, ['dart_puby_test', 'flutter clean']); diff --git a/test/exec_test.dart b/test/exec_test.dart index c0c5418..5c25e94 100644 --- a/test/exec_test.dart +++ b/test/exec_test.dart @@ -1,3 +1,4 @@ +import 'package:io/io.dart'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; @@ -8,7 +9,7 @@ void main() { final result = await testCommand(['exec', 'echo', 'foo']); final stdout = result.stdout; - expect(result.exitCode, 0); + expect(result.exitCode, ExitCode.success.code); // dart expectLine(stdout, [ 'dart_puby_test', diff --git a/test/fvm_version_not_installed_test.dart b/test/fvm_version_not_installed_test.dart index 29032f7..5c99989 100644 --- a/test/fvm_version_not_installed_test.dart +++ b/test/fvm_version_not_installed_test.dart @@ -11,7 +11,7 @@ void main() { ); final stdout = result.stdout; - expect(result.exitCode, ExitCode.unavailable.code); - expectLine(stdout, ['Flutter SDK: SDK Version : 1.17.0 is not installed.']); + expect(result.exitCode, isNot(ExitCode.success.code)); + expectLine(stdout, ['Run `fvm install 1.17.0` first']); }); } diff --git a/test/gen_test.dart b/test/gen_test.dart index 3cc9884..a543618 100644 --- a/test/gen_test.dart +++ b/test/gen_test.dart @@ -1,3 +1,4 @@ +import 'package:io/io.dart'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; @@ -11,7 +12,7 @@ void main() { final stdout = result.stdout; // Since these projects have no code generation, the command should fail - expect(result.exitCode, isNot(0)); + expect(result.exitCode, isNot(ExitCode.success.code)); // dart expectLine(stdout, ['dart_puby_test', 'dart $argString']); diff --git a/test/link_test.dart b/test/link_test.dart index dd5f629..f09d61a 100644 --- a/test/link_test.dart +++ b/test/link_test.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:io/io.dart'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; @@ -10,14 +11,16 @@ void main() { final result = await testCommand(['link']); final stdout = result.stdout; - expect(result.exitCode, 0); + expect(result.exitCode, ExitCode.success.code); // dart expectLine(stdout, ['dart_puby_test', 'Resolved dependencies for']); expectLine(stdout, ['dart_puby_test', 'dart pub get --offline']); + // The pub get should NOT run in the example app expectLine( stdout, [p.join('dart_puby_test', 'example'), 'dart pub get --offline'], + matches: false, ); // flutter diff --git a/test/mup_test.dart b/test/mup_test.dart index 96d8c8f..69205a4 100644 --- a/test/mup_test.dart +++ b/test/mup_test.dart @@ -1,3 +1,4 @@ +import 'package:io/io.dart'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; @@ -12,7 +13,7 @@ void main() { final result = await testCommand(['mup']); final stdout = result.stdout; - expect(result.exitCode, 0); + expect(result.exitCode, ExitCode.success.code); // dart expectLine(stdout, ['dart_puby_test', '"dart $argString"']); diff --git a/test/no_fvm_test.dart b/test/no_fvm_test.dart index 33cf3e7..16c6553 100644 --- a/test/no_fvm_test.dart +++ b/test/no_fvm_test.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:io/io.dart'; import 'package:test/test.dart'; import 'package:path/path.dart' as p; @@ -12,7 +13,7 @@ void main() { final result = await testCommand(['get', '--no-fvm']); final stdout = result.stdout; - expect(result.exitCode, 0); + expect(result.exitCode, ExitCode.success.code); expectLine(stdout, ['fvm_puby_test', message]); // Ensure the FVM Flutter version was not used expect( @@ -26,7 +27,7 @@ void main() { final result = await testCommand(['mup', '--no-fvm']); final stdout = result.stdout; - expect(result.exitCode, 0); + expect(result.exitCode, ExitCode.success.code); expectLine(stdout, ['fvm_puby_test', message]); }); @@ -34,7 +35,7 @@ void main() { final result = await testCommand(['link', '--no-fvm']); final stdout = result.stdout; - expect(result.exitCode, 0); + expect(result.exitCode, ExitCode.success.code); expectLine(stdout, ['fvm_puby_test', message]); expectLine(stdout, [p.join('fvm_puby_test', 'example'), message]); expectLine(stdout, [p.join('fvm_puby_test', 'nested'), message]); diff --git a/test/pub_test.dart b/test/pub_test.dart index daad207..acf2d5c 100644 --- a/test/pub_test.dart +++ b/test/pub_test.dart @@ -1,3 +1,4 @@ +import 'package:io/io.dart'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; @@ -8,14 +9,15 @@ void main() { final result = await testCommand(['get']); final stdout = result.stdout; - expect(result.exitCode, 0); + expect(result.exitCode, ExitCode.success.code); // project in build folder expectLine(stdout, [p.join('build_folder_test', 'build', 'web'), 'Skip']); // dart expectLine(stdout, ['dart_puby_test', 'dart pub get']); - expectLine(stdout, [p.join('dart_puby_test', 'example'), 'dart pub get']); + // Default exclusion + expectLine(stdout, [p.join('dart_puby_test', 'example'), 'Skip']); // flutter expectLine(stdout, ['flutter_puby_test', 'flutter pub get']); diff --git a/test/test_test.dart b/test/test_test.dart index 9190228..22588d9 100644 --- a/test/test_test.dart +++ b/test/test_test.dart @@ -1,3 +1,4 @@ +import 'package:io/io.dart'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; @@ -9,7 +10,7 @@ void main() { final stdout = result.stdout; // Since these projects have no tests, the command should fail - expect(result.exitCode, isNot(0)); + expect(result.exitCode, isNot(ExitCode.success.code)); // dart expectLine(stdout, ['dart_puby_test', 'flutter test --coverage']); diff --git a/test/unknown_command_test.dart b/test/unknown_command_test.dart index 8c72670..232f1a1 100644 --- a/test/unknown_command_test.dart +++ b/test/unknown_command_test.dart @@ -1,3 +1,4 @@ +import 'package:io/io.dart'; import 'package:test/test.dart'; import 'test_utils.dart'; @@ -7,7 +8,7 @@ void main() { final result = await testCommand(['asdf']); final stdout = result.stdout; - expect(result.exitCode, isNot(0)); - expectLine(stdout, ['Unknown command: asdf']); + expect(result.exitCode, ExitCode.usage.code); + expectLine(stdout, ['Unknown command. Exiting...']); }); } From 2d35db91c9bcce99e6dd1c4a25217c28badd86b7 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 13:51:43 -0400 Subject: [PATCH 06/28] Analysis updates --- CHANGELOG.md | 1 + analysis_options.yaml | 2 +- pubspec.yaml | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b41251..7778567 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Improves exit codes - Adds safety checks for FVM usage - Skips `pub get` in all example projects +- Bumps Dart SDK constraint to `^3.0.0` ## 1.35.0 - `puby link` no longer runs `pub get --offline` in flutter example projects diff --git a/analysis_options.yaml b/analysis_options.yaml index 9ecdaf3..1b1aabe 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1 +1 @@ -include: package:rexios_lints/dart/package.yaml +include: package:rexios_lints/dart/package_extra.yaml diff --git a/pubspec.yaml b/pubspec.yaml index ee514c5..8ec5220 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.36.0 homepage: https://github.com/Rexios80/puby environment: - sdk: ">=2.19.0 <4.0.0" + sdk: ^3.0.0 dependencies: yaml: ^3.1.1 @@ -18,7 +18,7 @@ dependencies: dev_dependencies: test: ^1.20.2 - rexios_lints: ^6.0.1 + rexios_lints: ^8.2.0 executables: puby: puby From 08778cae20bfa90d5035402bbd7c6f8151b19d20 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 13:52:53 -0400 Subject: [PATCH 07/28] Fixes --- .gitignore | 4 +++- test/link_test.dart | 13 +++++++------ test/no_fvm_test.dart | 11 ++++++----- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 2c8ce07..35c4ba9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,6 @@ build/ pubspec.lock # macOS -.DS_Store \ No newline at end of file +.DS_Store + +*.log \ No newline at end of file diff --git a/test/link_test.dart b/test/link_test.dart index f09d61a..f938518 100644 --- a/test/link_test.dart +++ b/test/link_test.dart @@ -1,7 +1,7 @@ import 'dart:io'; import 'package:io/io.dart'; -import 'package:path/path.dart' as p; +import 'package:path/path.dart' as path; import 'package:test/test.dart'; import 'test_utils.dart'; @@ -19,7 +19,7 @@ void main() { // The pub get should NOT run in the example app expectLine( stdout, - [p.join('dart_puby_test', 'example'), 'dart pub get --offline'], + [path.join('dart_puby_test', 'example'), 'dart pub get --offline'], matches: false, ); @@ -29,12 +29,12 @@ void main() { // The link should run in the example app expectLine( stdout, - [p.join('flutter_puby_test', 'example'), 'Resolved dependencies for'], + [path.join('flutter_puby_test', 'example'), 'Resolved dependencies for'], ); // The pub get should NOT run in the example app expectLine( stdout, - [p.join('flutter_puby_test', 'example'), 'flutter pub get --offline'], + [path.join('flutter_puby_test', 'example'), 'flutter pub get --offline'], matches: false, ); @@ -43,8 +43,9 @@ void main() { expectLine(stdout, ['fvm_puby_test', 'fvm flutter pub get --offline']); // Ensure the correct flutter version was used expect( - File('test_resources/fvm_puby_test/.dart_tool/version') - .readAsStringSync(), + File( + path.join('test_resources', 'fvm_puby_test', '.dart_tool', 'version'), + ).readAsStringSync(), '3.10.0', ); }); diff --git a/test/no_fvm_test.dart b/test/no_fvm_test.dart index 16c6553..9e98176 100644 --- a/test/no_fvm_test.dart +++ b/test/no_fvm_test.dart @@ -2,7 +2,7 @@ import 'dart:io'; import 'package:io/io.dart'; import 'package:test/test.dart'; -import 'package:path/path.dart' as p; +import 'package:path/path.dart' as path; import 'test_utils.dart'; @@ -17,8 +17,9 @@ void main() { expectLine(stdout, ['fvm_puby_test', message]); // Ensure the FVM Flutter version was not used expect( - File('test_resources/fvm_puby_test/.dart_tool/version') - .readAsStringSync(), + File( + path.join('test_resources', 'fvm_puby_test', '.dart_tool', 'version'), + ).readAsStringSync(), isNot('3.10.0'), ); }); @@ -37,7 +38,7 @@ void main() { expect(result.exitCode, ExitCode.success.code); expectLine(stdout, ['fvm_puby_test', message]); - expectLine(stdout, [p.join('fvm_puby_test', 'example'), message]); - expectLine(stdout, [p.join('fvm_puby_test', 'nested'), message]); + expectLine(stdout, [path.join('fvm_puby_test', 'example'), message]); + expectLine(stdout, [path.join('fvm_puby_test', 'nested'), message]); }); } From 6592bcb395ba662c86f8df0a2db2e7dddad49f75 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 14:02:21 -0400 Subject: [PATCH 08/28] ... --- .github/workflows/static-analysis.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml index 556d5d0..40d89ab 100644 --- a/.github/workflows/static-analysis.yaml +++ b/.github/workflows/static-analysis.yaml @@ -29,7 +29,9 @@ jobs: - name: Format run: dart format . --set-exit-if-changed - name: Analyze - run: dart analyze + run: dart analyze --fatal-infos + - name: custom_lint + run: dart run custom_lint - name: Test run: dart test --timeout 120s --concurrency 1 - name: Pana From 586b66f100c58c3cf032651291e2972c78ee09e2 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 15:11:11 -0400 Subject: [PATCH 09/28] Refactor pub test to use temp projects --- bin/projects.dart | 6 +- test/config_test.dart | 6 + test/fvm_version_not_installed_test.dart | 3 +- test/pub_test.dart | 126 ++++++++++++------ test/test_utils.dart | 83 +++++++++++- .../dart_puby_test/example/puby.yaml | 2 +- test_resources/dart_puby_test/pubspec.yaml | 3 +- 7 files changed, 179 insertions(+), 50 deletions(-) create mode 100644 test/config_test.dart diff --git a/bin/projects.dart b/bin/projects.dart index 9f1d7cf..a52f6ee 100644 --- a/bin/projects.dart +++ b/bin/projects.dart @@ -31,18 +31,18 @@ List findProjects() { final path = p.relative(absolutePath); final config = PubyConfig.fromProjectPath(path); - late final Pubspec? pubspec; + final Pubspec pubspec; try { pubspec = Pubspec.parse(pubspecEntity.readAsStringSync()); } catch (e) { print(red.wrap('Error parsing pubspec: $path')); - pubspec = null; + continue; } final Engine engine; if (fvmPaths.any(absolutePath.startsWith)) { engine = Engine.fvm; - } else if (pubspec?.dependencies['flutter'] != null) { + } else if (pubspec.dependencies['flutter'] != null) { engine = Engine.flutter; } else { engine = Engine.dart; diff --git a/test/config_test.dart b/test/config_test.dart new file mode 100644 index 0000000..97264ae --- /dev/null +++ b/test/config_test.dart @@ -0,0 +1,6 @@ +import 'package:test/test.dart'; + +import 'test_utils.dart'; +import 'package:path/path.dart' as path; + +void main() {} diff --git a/test/fvm_version_not_installed_test.dart b/test/fvm_version_not_installed_test.dart index 5c99989..643e952 100644 --- a/test/fvm_version_not_installed_test.dart +++ b/test/fvm_version_not_installed_test.dart @@ -7,7 +7,8 @@ void main() { test('FVM version not installed', () async { final result = await testCommand( ['get'], - workingDirectory: 'test_resources_2/fvm_version_not_installed_test', + // TODO: FIX THIS + // workingDirectory: 'test_resources_2/fvm_version_not_installed_test', ); final stdout = result.stdout; diff --git a/test/pub_test.dart b/test/pub_test.dart index acf2d5c..d440b02 100644 --- a/test/pub_test.dart +++ b/test/pub_test.dart @@ -1,47 +1,95 @@ import 'package:io/io.dart'; -import 'package:path/path.dart' as p; +import 'package:path/path.dart' as path; import 'package:test/test.dart'; import 'test_utils.dart'; void main() { - test('[engine] pub get', () async { - final result = await testCommand(['get']); - final stdout = result.stdout; - - expect(result.exitCode, ExitCode.success.code); - - // project in build folder - expectLine(stdout, [p.join('build_folder_test', 'build', 'web'), 'Skip']); - - // dart - expectLine(stdout, ['dart_puby_test', 'dart pub get']); - // Default exclusion - expectLine(stdout, [p.join('dart_puby_test', 'example'), 'Skip']); - - // flutter - expectLine(stdout, ['flutter_puby_test', 'flutter pub get']); - // Default exclusion - expectLine(stdout, [p.join('flutter_puby_test', 'example'), 'Skip']); - // Flutter pub get should run in the example project anyways - expectLine(stdout, ['Resolving dependencies in ./example...']); - - // fvm - expectLine(stdout, ['fvm_puby_test', 'fvm flutter pub get']); - // Default exclusion - expectLine(stdout, [p.join('fvm_puby_test', 'example'), 'Skip']); - // Flutter pub get should run in the example project anyways - // Can't test this with fvm since the output is the same as flutter - // expectLine(stdout, ['example', 'fvm flutter pub get']); - expectLine( - stdout, - [p.join('fvm_puby_test', 'nested'), 'fvm flutter pub get'], - ); - - // invalid_pubspec - expectLine(stdout, ['invalid_pubspec_test', 'Error parsing pubspec']); - - // transitive flutter - expectLine(stdout, ['transitive_flutter_test', 'dart pub get']); + group('[engine] pub get', () { + test('runs in all projects', () async { + final result = await testCommand(['get']); + final stdout = result.stdout; + + expect(result.exitCode, ExitCode.success.code); + + expectLine(stdout, ['dart_puby_test', 'dart pub get']); + expectLine(stdout, ['flutter_puby_test', 'flutter pub get']); + expectLine(stdout, ['fvm_puby_test', 'fvm flutter pub get']); + expectLine( + stdout, + [path.join('fvm_puby_test', 'nested'), 'fvm flutter pub get'], + ); + }); + + test('invlaid pubspec', () async { + final result = await testCommand( + ['get'], + projects: { + 'invalid_pubspec_test': { + 'pubspec.yaml': 'invalid', + }, + }, + ); + final stdout = result.stdout; + + expect(result.exitCode, ExitCode.usage.code); + + expectLine(stdout, ['invalid_pubspec_test', 'Error parsing pubspec']); + }); + + group('exclusions', () { + test('project in build folder', () async { + final result = await testCommand( + ['get'], + projects: { + 'build_folder_test': { + 'build/web/pubspec.yaml': pubspec('web'), + }, + }, + ); + final stdout = result.stdout; + + expect(result.exitCode, ExitCode.success.code); + + expectLine( + stdout, + [path.join('build_folder_test', 'build', 'web'), 'Skip'], + ); + }); + + group('example projects', () { + Future skipsExample( + TestProjects projects, { + String match = 'Resolving dependencies in `./example`...', + }) async { + final result = await testCommand(['get'], projects: projects); + final stdout = result.stdout; + + expect(result.exitCode, ExitCode.success.code); + + expectLine( + stdout, + [path.join(projects.keys.first, 'example'), 'Skip'], + ); + expectLine(stdout, [match]); + } + + test('dart', () async { + await skipsExample(dartProject); + }); + + test('flutter', () async { + await skipsExample(flutterProject); + }); + + test('fvm', () async { + await skipsExample( + fvmProject, + // This is different because of the older Flutter version + match: 'Resolving dependencies in ./example...', + ); + }); + }); + }); }); } diff --git a/test/test_utils.dart b/test/test_utils.dart index 3c5d409..c1c812b 100644 --- a/test/test_utils.dart +++ b/test/test_utils.dart @@ -2,19 +2,24 @@ import 'dart:convert'; import 'dart:io'; import 'package:test/test.dart'; +import 'package:path/path.dart' as path; final _decoder = Utf8Decoder(); +// Map of project name to file paths to file contents +typedef TestProjects = Map>; + Future testCommand( List arguments, { - String workingDirectory = 'test_resources', + TestProjects? projects, bool debug = false, }) async { - final levels = workingDirectory.split('/').length; - final root = '../' * levels; + final workingDirectory = createTestResources(projects ?? defaultProjects); + final puby = File(path.join('bin', 'puby.dart')).absolute.path; + final process = await Process.start( 'dart', - ['${root}bin/puby.dart', ...arguments], + [puby, ...arguments], workingDirectory: workingDirectory, ); @@ -46,3 +51,73 @@ void expectLine(dynamic stdout, List matchers, {bool matches = true}) { matches, ); } + +String createTestResources(Map> projects) { + final directory = Directory.systemTemp.createTempSync('test_resources'); + for (final MapEntry(:key, :value) in projects.entries) { + final project = key; + final files = value; + for (final MapEntry(:key, :value) in files.entries) { + final file = key; + final content = value; + File(path.join(directory.path, project, file)) + ..createSync(recursive: true) + ..writeAsStringSync(content); + } + } + return directory.path; +} + +String pubspec(String name, {bool flutter = false}) { + var pubspec = ''' +name: $name + +environment: + sdk: ^3.0.0 +'''; + + if (flutter) { + pubspec += ''' +dependencies: + flutter: + sdk: flutter +'''; + } + + return pubspec; +} + +String fvmrc(String version) => ''' +{ + "flutter": "$version", + "flavors": {} +}'''; + +final dartProject = { + 'dart_puby_test': { + 'pubspec.yaml': pubspec('dart_puby_test'), + 'example/pubspec.yaml': pubspec('example'), + }, +}; + +final flutterProject = { + 'flutter_puby_test': { + 'pubspec.yaml': pubspec('flutter_puby_test', flutter: true), + 'example/pubspec.yaml': pubspec('example', flutter: true), + }, +}; + +final fvmProject = { + 'fvm_puby_test': { + 'pubspec.yaml': pubspec('fvm_puby_test', flutter: true), + 'example/pubspec.yaml': pubspec('example', flutter: true), + 'nested/pubspec.yaml': pubspec('nested', flutter: true), + '.fvmrc': fvmrc('3.10.0'), + }, +}; + +final defaultProjects = { + ...dartProject, + ...flutterProject, + ...fvmProject, +}; diff --git a/test_resources/dart_puby_test/example/puby.yaml b/test_resources/dart_puby_test/example/puby.yaml index 64080c7..ae9adc6 100644 --- a/test_resources/dart_puby_test/example/puby.yaml +++ b/test_resources/dart_puby_test/example/puby.yaml @@ -1,3 +1,3 @@ exclude: - test - - pub run build_runner \ No newline at end of file + - pub run build_runner diff --git a/test_resources/dart_puby_test/pubspec.yaml b/test_resources/dart_puby_test/pubspec.yaml index a27a0d9..309159d 100644 --- a/test_resources/dart_puby_test/pubspec.yaml +++ b/test_resources/dart_puby_test/pubspec.yaml @@ -1,5 +1,4 @@ name: dart_puby_test -publish_to: none environment: - sdk: ">=2.16.2 <3.0.0" + sdk: ^3.0.0 From f9cf50057445f857bd7d8df60442ee5ca4d8d1a3 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 15:21:56 -0400 Subject: [PATCH 10/28] Refactor tests --- test/fvm_version_not_installed_test.dart | 8 ++++++-- test/gen_test.dart | 13 ------------- test/link_test.dart | 7 ++++++- test/no_fvm_test.dart | 7 ++++++- test/pub_test.dart | 4 ++-- test/test_test.dart | 12 ------------ test/test_utils.dart | 20 +++++++++++++++++--- 7 files changed, 37 insertions(+), 34 deletions(-) diff --git a/test/fvm_version_not_installed_test.dart b/test/fvm_version_not_installed_test.dart index 643e952..102aebc 100644 --- a/test/fvm_version_not_installed_test.dart +++ b/test/fvm_version_not_installed_test.dart @@ -7,8 +7,12 @@ void main() { test('FVM version not installed', () async { final result = await testCommand( ['get'], - // TODO: FIX THIS - // workingDirectory: 'test_resources_2/fvm_version_not_installed_test', + projects: { + 'fvm_version_not_installed_test': { + 'pubspec.yaml': pubspec('fvm_version_not_installed_test'), + '.fvmrc': fvmrc('1.17.0'), + }, + }, ); final stdout = result.stdout; diff --git a/test/gen_test.dart b/test/gen_test.dart index a543618..3a70654 100644 --- a/test/gen_test.dart +++ b/test/gen_test.dart @@ -1,5 +1,4 @@ import 'package:io/io.dart'; -import 'package:path/path.dart' as p; import 'package:test/test.dart'; import 'test_utils.dart'; @@ -11,22 +10,10 @@ void main() { final result = await testCommand(['gen']); final stdout = result.stdout; - // Since these projects have no code generation, the command should fail expect(result.exitCode, isNot(ExitCode.success.code)); - // dart expectLine(stdout, ['dart_puby_test', 'dart $argString']); - // Explicit exclusion - expectLine(stdout, [p.join('dart_puby_test', 'example'), 'Skip']); - - // flutter expectLine(stdout, ['flutter_puby_test', 'flutter $argString']); - // Explicit exclusion - expectLine(stdout, [p.join('flutter_puby_test', 'example'), 'Skip']); - - // fvm expectLine(stdout, ['fvm_puby_test', 'fvm flutter $argString']); - // Explicit exclusion - expectLine(stdout, [p.join('fvm_puby_test', 'example'), 'Skip']); }); } diff --git a/test/link_test.dart b/test/link_test.dart index f938518..3d1d9da 100644 --- a/test/link_test.dart +++ b/test/link_test.dart @@ -44,7 +44,12 @@ void main() { // Ensure the correct flutter version was used expect( File( - path.join('test_resources', 'fvm_puby_test', '.dart_tool', 'version'), + path.join( + result.workingDirectory, + 'fvm_puby_test', + '.dart_tool', + 'version', + ), ).readAsStringSync(), '3.10.0', ); diff --git a/test/no_fvm_test.dart b/test/no_fvm_test.dart index 9e98176..8d3faa1 100644 --- a/test/no_fvm_test.dart +++ b/test/no_fvm_test.dart @@ -18,7 +18,12 @@ void main() { // Ensure the FVM Flutter version was not used expect( File( - path.join('test_resources', 'fvm_puby_test', '.dart_tool', 'version'), + path.join( + result.workingDirectory, + 'fvm_puby_test', + '.dart_tool', + 'version', + ), ).readAsStringSync(), isNot('3.10.0'), ); diff --git a/test/pub_test.dart b/test/pub_test.dart index d440b02..62f21d7 100644 --- a/test/pub_test.dart +++ b/test/pub_test.dart @@ -21,7 +21,7 @@ void main() { ); }); - test('invlaid pubspec', () async { + test('handles invlaid pubspec', () async { final result = await testCommand( ['get'], projects: { @@ -37,7 +37,7 @@ void main() { expectLine(stdout, ['invalid_pubspec_test', 'Error parsing pubspec']); }); - group('exclusions', () { + group('excludes', () { test('project in build folder', () async { final result = await testCommand( ['get'], diff --git a/test/test_test.dart b/test/test_test.dart index 22588d9..c081867 100644 --- a/test/test_test.dart +++ b/test/test_test.dart @@ -1,5 +1,4 @@ import 'package:io/io.dart'; -import 'package:path/path.dart' as p; import 'package:test/test.dart'; import 'test_utils.dart'; @@ -12,19 +11,8 @@ void main() { // Since these projects have no tests, the command should fail expect(result.exitCode, isNot(ExitCode.success.code)); - // dart expectLine(stdout, ['dart_puby_test', 'flutter test --coverage']); - // Explicit exclusion - expectLine(stdout, [p.join('dart_puby_test', 'example'), 'Skip']); - - // flutter expectLine(stdout, ['flutter_puby_test', 'flutter test --coverage']); - // Explicit exclusion - expectLine(stdout, [p.join('flutter_puby_test', 'example'), 'Skip']); - - // fvm expectLine(stdout, ['fvm_puby_test', 'fvm flutter test --coverage']); - // Explicit exclusion - expectLine(stdout, [p.join('fvm_puby_test', 'example'), 'Skip']); }); } diff --git a/test/test_utils.dart b/test/test_utils.dart index c1c812b..365dd8f 100644 --- a/test/test_utils.dart +++ b/test/test_utils.dart @@ -9,7 +9,21 @@ final _decoder = Utf8Decoder(); // Map of project name to file paths to file contents typedef TestProjects = Map>; -Future testCommand( +class PubyProcessResult { + final String workingDirectory; + final int exitCode; + final String stdout; + final String stderr; + + PubyProcessResult( + this.workingDirectory, + this.exitCode, + this.stdout, + this.stderr, + ); +} + +Future testCommand( List arguments, { TestProjects? projects, bool debug = false, @@ -33,8 +47,8 @@ Future testCommand( final processStderr = process.stderr.map(handleLine).join('\n'); final exitCode = await process.exitCode; - return ProcessResult( - process.pid, + return PubyProcessResult( + workingDirectory, exitCode, await processStdout, await processStderr, From badacd24ca264811b8147d034cf5711f0999abd9 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 15:23:27 -0400 Subject: [PATCH 11/28] Remove test resources --- test_resources/.gitignore | 3 --- test_resources/build_folder_test/build/web/pubspec.yaml | 5 ----- test_resources/dart_puby_test/example/pubspec.yaml | 5 ----- test_resources/dart_puby_test/example/puby.yaml | 3 --- test_resources/dart_puby_test/pubspec.yaml | 4 ---- test_resources/flutter_puby_test/example/pubspec.yaml | 9 --------- test_resources/flutter_puby_test/example/puby.yaml | 3 --- test_resources/flutter_puby_test/pubspec.yaml | 9 --------- test_resources/fvm_puby_test/.fvmrc | 4 ---- test_resources/fvm_puby_test/example/pubspec.yaml | 9 --------- test_resources/fvm_puby_test/example/puby.yaml | 3 --- test_resources/fvm_puby_test/nested/pubspec.yaml | 9 --------- test_resources/fvm_puby_test/pubspec.yaml | 9 --------- test_resources/invalid_pubspec_test/pubspec.yaml | 0 test_resources/invalid_pubspec_test/puby.yaml | 4 ---- test_resources/transitive_flutter_test/pubspec.yaml | 9 --------- test_resources_2/.gitignore | 4 ---- test_resources_2/fvm_version_not_installed_test/.fvmrc | 4 ---- .../fvm_version_not_installed_test/pubspec.yaml | 9 --------- 19 files changed, 105 deletions(-) delete mode 100644 test_resources/.gitignore delete mode 100644 test_resources/build_folder_test/build/web/pubspec.yaml delete mode 100644 test_resources/dart_puby_test/example/pubspec.yaml delete mode 100644 test_resources/dart_puby_test/example/puby.yaml delete mode 100644 test_resources/dart_puby_test/pubspec.yaml delete mode 100644 test_resources/flutter_puby_test/example/pubspec.yaml delete mode 100644 test_resources/flutter_puby_test/example/puby.yaml delete mode 100644 test_resources/flutter_puby_test/pubspec.yaml delete mode 100644 test_resources/fvm_puby_test/.fvmrc delete mode 100644 test_resources/fvm_puby_test/example/pubspec.yaml delete mode 100644 test_resources/fvm_puby_test/example/puby.yaml delete mode 100644 test_resources/fvm_puby_test/nested/pubspec.yaml delete mode 100644 test_resources/fvm_puby_test/pubspec.yaml delete mode 100644 test_resources/invalid_pubspec_test/pubspec.yaml delete mode 100644 test_resources/invalid_pubspec_test/puby.yaml delete mode 100644 test_resources/transitive_flutter_test/pubspec.yaml delete mode 100644 test_resources_2/.gitignore delete mode 100644 test_resources_2/fvm_version_not_installed_test/.fvmrc delete mode 100644 test_resources_2/fvm_version_not_installed_test/pubspec.yaml diff --git a/test_resources/.gitignore b/test_resources/.gitignore deleted file mode 100644 index f568edd..0000000 --- a/test_resources/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.dart_tool -**/.fvm -!build_folder_test/build \ No newline at end of file diff --git a/test_resources/build_folder_test/build/web/pubspec.yaml b/test_resources/build_folder_test/build/web/pubspec.yaml deleted file mode 100644 index a07a434..0000000 --- a/test_resources/build_folder_test/build/web/pubspec.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: web -publish_to: none - -environment: - sdk: ">=2.18.0 <3.0.0" diff --git a/test_resources/dart_puby_test/example/pubspec.yaml b/test_resources/dart_puby_test/example/pubspec.yaml deleted file mode 100644 index 3da76f8..0000000 --- a/test_resources/dart_puby_test/example/pubspec.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: example -publish_to: none - -environment: - sdk: ">=2.16.2 <3.0.0" diff --git a/test_resources/dart_puby_test/example/puby.yaml b/test_resources/dart_puby_test/example/puby.yaml deleted file mode 100644 index ae9adc6..0000000 --- a/test_resources/dart_puby_test/example/puby.yaml +++ /dev/null @@ -1,3 +0,0 @@ -exclude: - - test - - pub run build_runner diff --git a/test_resources/dart_puby_test/pubspec.yaml b/test_resources/dart_puby_test/pubspec.yaml deleted file mode 100644 index 309159d..0000000 --- a/test_resources/dart_puby_test/pubspec.yaml +++ /dev/null @@ -1,4 +0,0 @@ -name: dart_puby_test - -environment: - sdk: ^3.0.0 diff --git a/test_resources/flutter_puby_test/example/pubspec.yaml b/test_resources/flutter_puby_test/example/pubspec.yaml deleted file mode 100644 index 3776aab..0000000 --- a/test_resources/flutter_puby_test/example/pubspec.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: example -publish_to: none - -environment: - sdk: ">=2.16.2 <3.0.0" - -dependencies: - flutter: - sdk: flutter diff --git a/test_resources/flutter_puby_test/example/puby.yaml b/test_resources/flutter_puby_test/example/puby.yaml deleted file mode 100644 index 64080c7..0000000 --- a/test_resources/flutter_puby_test/example/puby.yaml +++ /dev/null @@ -1,3 +0,0 @@ -exclude: - - test - - pub run build_runner \ No newline at end of file diff --git a/test_resources/flutter_puby_test/pubspec.yaml b/test_resources/flutter_puby_test/pubspec.yaml deleted file mode 100644 index 3e74567..0000000 --- a/test_resources/flutter_puby_test/pubspec.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: flutter_puby_test -publish_to: none - -environment: - sdk: ">=2.16.2 <3.0.0" - -dependencies: - flutter: - sdk: flutter diff --git a/test_resources/fvm_puby_test/.fvmrc b/test_resources/fvm_puby_test/.fvmrc deleted file mode 100644 index ceeca18..0000000 --- a/test_resources/fvm_puby_test/.fvmrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flutter": "3.10.0", - "flavors": {} -} \ No newline at end of file diff --git a/test_resources/fvm_puby_test/example/pubspec.yaml b/test_resources/fvm_puby_test/example/pubspec.yaml deleted file mode 100644 index 0aa57e8..0000000 --- a/test_resources/fvm_puby_test/example/pubspec.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: example -publish_to: none - -environment: - sdk: ^3.0.0 - -dependencies: - flutter: - sdk: flutter diff --git a/test_resources/fvm_puby_test/example/puby.yaml b/test_resources/fvm_puby_test/example/puby.yaml deleted file mode 100644 index 64080c7..0000000 --- a/test_resources/fvm_puby_test/example/puby.yaml +++ /dev/null @@ -1,3 +0,0 @@ -exclude: - - test - - pub run build_runner \ No newline at end of file diff --git a/test_resources/fvm_puby_test/nested/pubspec.yaml b/test_resources/fvm_puby_test/nested/pubspec.yaml deleted file mode 100644 index 958c00d..0000000 --- a/test_resources/fvm_puby_test/nested/pubspec.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: nested -publish_to: none - -environment: - sdk: ^3.0.0 - -dependencies: - flutter: - sdk: flutter diff --git a/test_resources/fvm_puby_test/pubspec.yaml b/test_resources/fvm_puby_test/pubspec.yaml deleted file mode 100644 index 573d629..0000000 --- a/test_resources/fvm_puby_test/pubspec.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: fvm_puby_test -publish_to: none - -environment: - sdk: ^3.0.0 - -dependencies: - flutter: - sdk: flutter diff --git a/test_resources/invalid_pubspec_test/pubspec.yaml b/test_resources/invalid_pubspec_test/pubspec.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/test_resources/invalid_pubspec_test/puby.yaml b/test_resources/invalid_pubspec_test/puby.yaml deleted file mode 100644 index 508bff7..0000000 --- a/test_resources/invalid_pubspec_test/puby.yaml +++ /dev/null @@ -1,4 +0,0 @@ -exclude: - - test - - pub get - - pub upgrade \ No newline at end of file diff --git a/test_resources/transitive_flutter_test/pubspec.yaml b/test_resources/transitive_flutter_test/pubspec.yaml deleted file mode 100644 index 55a5a31..0000000 --- a/test_resources/transitive_flutter_test/pubspec.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: transitive_flutter_test -publish_to: none - -environment: - sdk: ">=2.16.2 <3.0.0" - -dependencies: - flutter_puby_test: - path: ../flutter_puby_test diff --git a/test_resources_2/.gitignore b/test_resources_2/.gitignore deleted file mode 100644 index f03451b..0000000 --- a/test_resources_2/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.dart_tool -pubspec.lock -**/.fvm -!build_folder_test/build \ No newline at end of file diff --git a/test_resources_2/fvm_version_not_installed_test/.fvmrc b/test_resources_2/fvm_version_not_installed_test/.fvmrc deleted file mode 100644 index e553dbb..0000000 --- a/test_resources_2/fvm_version_not_installed_test/.fvmrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flutter": "1.17.0", - "flavors": {} -} \ No newline at end of file diff --git a/test_resources_2/fvm_version_not_installed_test/pubspec.yaml b/test_resources_2/fvm_version_not_installed_test/pubspec.yaml deleted file mode 100644 index 9d25361..0000000 --- a/test_resources_2/fvm_version_not_installed_test/pubspec.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: fvm_puby_test -publish_to: none - -environment: - sdk: ">=2.16.2 <3.0.0" - -dependencies: - flutter: - sdk: flutter From d606ab90d0d6ae33a8aa751eb70bec60be02501c Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 15:29:10 -0400 Subject: [PATCH 12/28] Add config test --- test/config_test.dart | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/test/config_test.dart b/test/config_test.dart index 97264ae..90a85ef 100644 --- a/test/config_test.dart +++ b/test/config_test.dart @@ -1,6 +1,29 @@ +import 'package:io/io.dart'; import 'package:test/test.dart'; import 'test_utils.dart'; import 'package:path/path.dart' as path; -void main() {} +void main() { + group('config', () { + test('exclude', () async { + final result = await testCommand( + ['gen'], + projects: { + 'puby_yaml_test': { + 'pubspec.yaml': pubspec('puby_yaml_test'), + 'puby.yaml': ''' +exclude: + - pub run build_runner +''', + }, + }, + ); + + // Since the code generation doesn't actually run the command should succeed + expect(result.exitCode, ExitCode.success.code); + + expectLine(result, [path.join('puby_yaml_test'), 'Skip']); + }); + }); +} From 0442042910cb54f126f3543af73250ab1c3bac68 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 15:30:08 -0400 Subject: [PATCH 13/28] ... --- test/config_test.dart | 3 ++- test/test_utils.dart | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/config_test.dart b/test/config_test.dart index 90a85ef..82280bc 100644 --- a/test/config_test.dart +++ b/test/config_test.dart @@ -19,11 +19,12 @@ exclude: }, }, ); + final stdout = result.stdout; // Since the code generation doesn't actually run the command should succeed expect(result.exitCode, ExitCode.success.code); - expectLine(result, [path.join('puby_yaml_test'), 'Skip']); + expectLine(stdout, [path.join('puby_yaml_test'), 'Skip']); }); }); } diff --git a/test/test_utils.dart b/test/test_utils.dart index 365dd8f..032dc9e 100644 --- a/test/test_utils.dart +++ b/test/test_utils.dart @@ -55,7 +55,7 @@ Future testCommand( ); } -void expectLine(dynamic stdout, List matchers, {bool matches = true}) { +void expectLine(String stdout, List matchers, {bool matches = true}) { final lines = (stdout as String).split('\n'); expect( lines.any( From 52f0d2f79426dedca102a0759906ae0f0570e1f7 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 15:30:26 -0400 Subject: [PATCH 14/28] ... --- test/test_utils.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_utils.dart b/test/test_utils.dart index 032dc9e..0978468 100644 --- a/test/test_utils.dart +++ b/test/test_utils.dart @@ -56,7 +56,7 @@ Future testCommand( } void expectLine(String stdout, List matchers, {bool matches = true}) { - final lines = (stdout as String).split('\n'); + final lines = stdout.split('\n'); expect( lines.any( (line) => From df688075070f109262ae0c5b34a03c6b7275a655 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 15:31:02 -0400 Subject: [PATCH 15/28] Update action --- .github/workflows/static-analysis.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml index 40d89ab..c3fce54 100644 --- a/.github/workflows/static-analysis.yaml +++ b/.github/workflows/static-analysis.yaml @@ -27,13 +27,13 @@ jobs: - name: Pub get run: dart pub get - name: Format - run: dart format . --set-exit-if-changed + run: dart format --set-exit-if-changed . - name: Analyze run: dart analyze --fatal-infos - name: custom_lint run: dart run custom_lint - name: Test - run: dart test --timeout 120s --concurrency 1 + run: dart test --timeout 120s - name: Pana run: | dart pub global activate pana From 958f617913014a224c7b552a4685e3571392bb11 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 15:33:13 -0400 Subject: [PATCH 16/28] Group --no-fvm tests --- test/no_fvm_test.dart | 74 ++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/test/no_fvm_test.dart b/test/no_fvm_test.dart index 8d3faa1..bf5015e 100644 --- a/test/no_fvm_test.dart +++ b/test/no_fvm_test.dart @@ -9,41 +9,43 @@ import 'test_utils.dart'; const message = 'Project uses FVM, but FVM support is disabled'; void main() { - test('--no-fvm', () async { - final result = await testCommand(['get', '--no-fvm']); - final stdout = result.stdout; - - expect(result.exitCode, ExitCode.success.code); - expectLine(stdout, ['fvm_puby_test', message]); - // Ensure the FVM Flutter version was not used - expect( - File( - path.join( - result.workingDirectory, - 'fvm_puby_test', - '.dart_tool', - 'version', - ), - ).readAsStringSync(), - isNot('3.10.0'), - ); - }); - - test('--no-fvm on convenience command', () async { - final result = await testCommand(['mup', '--no-fvm']); - final stdout = result.stdout; - - expect(result.exitCode, ExitCode.success.code); - expectLine(stdout, ['fvm_puby_test', message]); - }); - - test('--no-fvm on link command', () async { - final result = await testCommand(['link', '--no-fvm']); - final stdout = result.stdout; - - expect(result.exitCode, ExitCode.success.code); - expectLine(stdout, ['fvm_puby_test', message]); - expectLine(stdout, [path.join('fvm_puby_test', 'example'), message]); - expectLine(stdout, [path.join('fvm_puby_test', 'nested'), message]); + group('--no-fvm', () { + test('on pub get', () async { + final result = await testCommand(['get', '--no-fvm']); + final stdout = result.stdout; + + expect(result.exitCode, ExitCode.success.code); + expectLine(stdout, ['fvm_puby_test', message]); + // Ensure the FVM Flutter version was not used + expect( + File( + path.join( + result.workingDirectory, + 'fvm_puby_test', + '.dart_tool', + 'version', + ), + ).readAsStringSync(), + isNot('3.10.0'), + ); + }); + + test('on convenience command', () async { + final result = await testCommand(['mup', '--no-fvm']); + final stdout = result.stdout; + + expect(result.exitCode, ExitCode.success.code); + expectLine(stdout, ['fvm_puby_test', message]); + }); + + test('on link command', () async { + final result = await testCommand(['link', '--no-fvm']); + final stdout = result.stdout; + + expect(result.exitCode, ExitCode.success.code); + expectLine(stdout, ['fvm_puby_test', message]); + expectLine(stdout, [path.join('fvm_puby_test', 'example'), message]); + expectLine(stdout, [path.join('fvm_puby_test', 'nested'), message]); + }); }); } From 0c88da90c819553aecac28b14413e3b524d7bd77 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 15:34:03 -0400 Subject: [PATCH 17/28] Remove test timeout in action --- .github/workflows/static-analysis.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml index c3fce54..4d179fd 100644 --- a/.github/workflows/static-analysis.yaml +++ b/.github/workflows/static-analysis.yaml @@ -33,7 +33,7 @@ jobs: - name: custom_lint run: dart run custom_lint - name: Test - run: dart test --timeout 120s + run: dart test - name: Pana run: | dart pub global activate pana From 05f676468c3938b75b4808cbb7ad8df6a07f27f9 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 15:43:08 -0400 Subject: [PATCH 18/28] Debug tests --- test/gen_test.dart | 2 +- test/link_test.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/gen_test.dart b/test/gen_test.dart index 3a70654..fbcd26f 100644 --- a/test/gen_test.dart +++ b/test/gen_test.dart @@ -7,7 +7,7 @@ const argString = 'pub run build_runner build --delete-conflicting-outputs'; void main() { test('[engine] gen', () async { - final result = await testCommand(['gen']); + final result = await testCommand(['gen'], debug: true); final stdout = result.stdout; expect(result.exitCode, isNot(ExitCode.success.code)); diff --git a/test/link_test.dart b/test/link_test.dart index 3d1d9da..76984f4 100644 --- a/test/link_test.dart +++ b/test/link_test.dart @@ -8,7 +8,7 @@ import 'test_utils.dart'; void main() { test('puby link', () async { - final result = await testCommand(['link']); + final result = await testCommand(['link'], debug: true); final stdout = result.stdout; expect(result.exitCode, ExitCode.success.code); From 7eceeb23eba9208c7651655c31f77581993cf02c Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 15:43:57 -0400 Subject: [PATCH 19/28] Only run action on push to master --- .github/workflows/static-analysis.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml index 4d179fd..8b5b923 100644 --- a/.github/workflows/static-analysis.yaml +++ b/.github/workflows/static-analysis.yaml @@ -1,6 +1,8 @@ name: Static Analysis on: push: + branches: + - master pull_request: concurrency: From d71c0f100cbfde2bb7f983a0d5d01d31d5cb7085 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 15:50:03 -0400 Subject: [PATCH 20/28] Attempt to set up fvm more --- .github/workflows/static-analysis.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml index 8b5b923..01bfb7d 100644 --- a/.github/workflows/static-analysis.yaml +++ b/.github/workflows/static-analysis.yaml @@ -25,7 +25,10 @@ jobs: echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH fvm install 3.10.0 --setup fvm install stable --setup + fvm global 3.10.0 + flutter doctor fvm global stable + flutter doctor - name: Pub get run: dart pub get - name: Format From 2656107de00eca1bfc37ea0b0618ac94f55536b8 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 15:56:31 -0400 Subject: [PATCH 21/28] ... --- .github/workflows/static-analysis.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml index 01bfb7d..faef945 100644 --- a/.github/workflows/static-analysis.yaml +++ b/.github/workflows/static-analysis.yaml @@ -26,9 +26,9 @@ jobs: fvm install 3.10.0 --setup fvm install stable --setup fvm global 3.10.0 - flutter doctor + fvm flutter doctor fvm global stable - flutter doctor + fvm flutter doctor - name: Pub get run: dart pub get - name: Format From b88a9124de98d6e0291dbf2544b9552873a54a22 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 16:04:13 -0400 Subject: [PATCH 22/28] ... --- test/gen_test.dart | 2 +- test/link_test.dart | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/gen_test.dart b/test/gen_test.dart index fbcd26f..3a70654 100644 --- a/test/gen_test.dart +++ b/test/gen_test.dart @@ -7,7 +7,7 @@ const argString = 'pub run build_runner build --delete-conflicting-outputs'; void main() { test('[engine] gen', () async { - final result = await testCommand(['gen'], debug: true); + final result = await testCommand(['gen']); final stdout = result.stdout; expect(result.exitCode, isNot(ExitCode.success.code)); diff --git a/test/link_test.dart b/test/link_test.dart index 76984f4..c4190c1 100644 --- a/test/link_test.dart +++ b/test/link_test.dart @@ -8,7 +8,9 @@ import 'test_utils.dart'; void main() { test('puby link', () async { - final result = await testCommand(['link'], debug: true); + // A pub get must be done before link will work + await testCommand(['get']); + final result = await testCommand(['link']); final stdout = result.stdout; expect(result.exitCode, ExitCode.success.code); From c35d5fdf81261faa32bf2f93b6672df593a988f2 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 16:05:31 -0400 Subject: [PATCH 23/28] ... --- test/link_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/link_test.dart b/test/link_test.dart index c4190c1..f2837e8 100644 --- a/test/link_test.dart +++ b/test/link_test.dart @@ -8,7 +8,7 @@ import 'test_utils.dart'; void main() { test('puby link', () async { - // A pub get must be done before link will work + // Pub get must run before link will work in FVM projects await testCommand(['get']); final result = await testCommand(['link']); final stdout = result.stdout; From 26e453d4bce3bea00828e90c599a57e2859abe72 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 16:17:33 -0400 Subject: [PATCH 24/28] debugging again --- test/link_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/link_test.dart b/test/link_test.dart index f2837e8..4c85f9b 100644 --- a/test/link_test.dart +++ b/test/link_test.dart @@ -10,7 +10,7 @@ void main() { test('puby link', () async { // Pub get must run before link will work in FVM projects await testCommand(['get']); - final result = await testCommand(['link']); + final result = await testCommand(['link'], debug: true); final stdout = result.stdout; expect(result.exitCode, ExitCode.success.code); From c4d26b7d4f00dd2f32c9a16f3caaaaa2984be1e7 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 16:22:28 -0400 Subject: [PATCH 25/28] ... --- test/link_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/link_test.dart b/test/link_test.dart index 4c85f9b..dccffa8 100644 --- a/test/link_test.dart +++ b/test/link_test.dart @@ -9,7 +9,7 @@ import 'test_utils.dart'; void main() { test('puby link', () async { // Pub get must run before link will work in FVM projects - await testCommand(['get']); + await testCommand(['get'], debug: true); final result = await testCommand(['link'], debug: true); final stdout = result.stdout; From a06d701f42fa8e68263c5d4be431e0b55d8c11cb Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 16:29:16 -0400 Subject: [PATCH 26/28] Longer timeout --- test/link_test.dart | 100 ++++++++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 45 deletions(-) diff --git a/test/link_test.dart b/test/link_test.dart index dccffa8..2a6a206 100644 --- a/test/link_test.dart +++ b/test/link_test.dart @@ -7,53 +7,63 @@ import 'package:test/test.dart'; import 'test_utils.dart'; void main() { - test('puby link', () async { - // Pub get must run before link will work in FVM projects - await testCommand(['get'], debug: true); - final result = await testCommand(['link'], debug: true); - final stdout = result.stdout; + test( + 'puby link', + () async { + // Pub get must run before link will work in FVM projects + await testCommand(['get']); + final result = await testCommand(['link']); + final stdout = result.stdout; - expect(result.exitCode, ExitCode.success.code); + expect(result.exitCode, ExitCode.success.code); - // dart - expectLine(stdout, ['dart_puby_test', 'Resolved dependencies for']); - expectLine(stdout, ['dart_puby_test', 'dart pub get --offline']); - // The pub get should NOT run in the example app - expectLine( - stdout, - [path.join('dart_puby_test', 'example'), 'dart pub get --offline'], - matches: false, - ); + // dart + expectLine(stdout, ['dart_puby_test', 'Resolved dependencies for']); + expectLine(stdout, ['dart_puby_test', 'dart pub get --offline']); + // The pub get should NOT run in the example app + expectLine( + stdout, + [path.join('dart_puby_test', 'example'), 'dart pub get --offline'], + matches: false, + ); - // flutter - expectLine(stdout, ['flutter_puby_test', 'Resolved dependencies for']); - expectLine(stdout, ['flutter_puby_test', 'flutter pub get --offline']); - // The link should run in the example app - expectLine( - stdout, - [path.join('flutter_puby_test', 'example'), 'Resolved dependencies for'], - ); - // The pub get should NOT run in the example app - expectLine( - stdout, - [path.join('flutter_puby_test', 'example'), 'flutter pub get --offline'], - matches: false, - ); + // flutter + expectLine(stdout, ['flutter_puby_test', 'Resolved dependencies for']); + expectLine(stdout, ['flutter_puby_test', 'flutter pub get --offline']); + // The link should run in the example app + expectLine( + stdout, + [ + path.join('flutter_puby_test', 'example'), + 'Resolved dependencies for' + ], + ); + // The pub get should NOT run in the example app + expectLine( + stdout, + [ + path.join('flutter_puby_test', 'example'), + 'flutter pub get --offline' + ], + matches: false, + ); - // fvm - expectLine(stdout, ['fvm_puby_test', 'Resolved dependencies for']); - expectLine(stdout, ['fvm_puby_test', 'fvm flutter pub get --offline']); - // Ensure the correct flutter version was used - expect( - File( - path.join( - result.workingDirectory, - 'fvm_puby_test', - '.dart_tool', - 'version', - ), - ).readAsStringSync(), - '3.10.0', - ); - }); + // fvm + expectLine(stdout, ['fvm_puby_test', 'Resolved dependencies for']); + expectLine(stdout, ['fvm_puby_test', 'fvm flutter pub get --offline']); + // Ensure the correct flutter version was used + expect( + File( + path.join( + result.workingDirectory, + 'fvm_puby_test', + '.dart_tool', + 'version', + ), + ).readAsStringSync(), + '3.10.0', + ); + }, + timeout: const Timeout(Duration(seconds: 120)), + ); } From 26e50c7d59b5c4821e77275143faca4aefaa77c1 Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 16:29:50 -0400 Subject: [PATCH 27/28] ... --- test/link_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/link_test.dart b/test/link_test.dart index 2a6a206..dbc93bc 100644 --- a/test/link_test.dart +++ b/test/link_test.dart @@ -35,7 +35,7 @@ void main() { stdout, [ path.join('flutter_puby_test', 'example'), - 'Resolved dependencies for' + 'Resolved dependencies for', ], ); // The pub get should NOT run in the example app @@ -43,7 +43,7 @@ void main() { stdout, [ path.join('flutter_puby_test', 'example'), - 'flutter pub get --offline' + 'flutter pub get --offline', ], matches: false, ); From 5d94f820c3589cc846f915e81b548e4d871db54c Mon Sep 17 00:00:00 2001 From: Rexios Date: Fri, 11 Oct 2024 16:44:00 -0400 Subject: [PATCH 28/28] Cleanup --- bin/commands.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/commands.dart b/bin/commands.dart index b2cda9e..f7dbab4 100644 --- a/bin/commands.dart +++ b/bin/commands.dart @@ -143,7 +143,7 @@ extension ProjectCommandExtension on ProjectCommand { stopwatch.stop(); // Skip error handling if the command was successful or this is a raw command - if (raw || exitCode == 0) { + if (raw || exitCode == ExitCode.success.code) { print( green.wrap( 'Ran "$argString" in $pathString (${stopwatch.prettyPrint()})',