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,