Skip to content

Commit

Permalink
Fix fvm resolution and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexios80 committed Apr 26, 2024
1 parent 7f4ecfd commit fbc1a17
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 54 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.35.0
- `puby link` no longer runs `pub get --offline` in flutter example projects
- Fixes `--no-fvm` flag for `puby link`
- Fixes nested fvm project resolution

## 1.34.0
- Adds `puby relink` as an alias for `puby clean && puby link`
- `puby link` now respects the fvm flutter version during linking
Expand Down
2 changes: 1 addition & 1 deletion bin/projects.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ List<Project> findProjects() {
}

final Engine engine;
if (fvmPaths.contains(absolutePath)) {
if (fvmPaths.any(absolutePath.startsWith)) {
engine = Engine.fvm;
} else if (pubspec?.dependencies['flutter'] != null) {
engine = Engine.flutter;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: puby
description: Run commands in all projects in the current directory. Handle monorepos with ease.
version: 1.34.0
version: 1.35.0
homepage: https://github.com/Rexios80/puby

environment:
Expand Down
7 changes: 5 additions & 2 deletions test/clean_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ void main() {
);

// fvm
expectLine(stdout, ['fvm_puby_test', 'flutter clean']);
expectLine(stdout, [p.join('fvm_puby_test', 'example'), 'flutter clean']);
expectLine(stdout, ['fvm_puby_test', 'fvm flutter clean']);
expectLine(
stdout,
[p.join('fvm_puby_test', 'example'), 'fvm flutter clean'],
);
});
}
17 changes: 5 additions & 12 deletions test/gen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:test/test.dart';

import 'test_utils.dart';

const argString = 'pub run build_runner build --delete-conflicting-outputs';

void main() {
test('[engine] gen', () async {
final result = await testCommand(['gen']);
Expand All @@ -12,26 +14,17 @@ void main() {
expect(result.exitCode, isNot(0));

// dart
expectLine(stdout, [
'dart_puby_test',
'dart pub run build_runner build --delete-conflicting-outputs',
]);
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 pub run build_runner build --delete-conflicting-outputs',
]);
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 pub run build_runner build --delete-conflicting-outputs',
]);
expectLine(stdout, ['fvm_puby_test', 'fvm flutter $argString']);
// Explicit exclusion
expectLine(stdout, [p.join('fvm_puby_test', 'example'), 'Skip']);
});
Expand Down
4 changes: 2 additions & 2 deletions test/link_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ void main() {
// The link should run in the example app
expectLine(
stdout,
['flutter_puby_test/example', 'Resolved dependencies for'],
[p.join('flutter_puby_test', 'example'), 'Resolved dependencies for'],
);
// The pub get should NOT run in the example app
expectLine(
stdout,
['flutter_puby_test/example', 'flutter pub get --offline'],
[p.join('flutter_puby_test', 'example'), 'flutter pub get --offline'],
matches: false,
);

Expand Down
41 changes: 17 additions & 24 deletions test/mup_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:test/test.dart';

import 'test_utils.dart';

const argString = 'pub upgrade --major-versions';

void main() {
test(
'[engine] mup',
Expand All @@ -13,34 +15,25 @@ void main() {
expect(result.exitCode, 0);

// dart
expectLine(stdout, [
'dart_puby_test',
'"dart pub upgrade --major-versions"',
]);
expectLine(stdout, [
p.join('dart_puby_test', 'example'),
'"dart pub upgrade --major-versions"',
]);
expectLine(stdout, ['dart_puby_test', '"dart $argString"']);
expectLine(
stdout,
[p.join('dart_puby_test', 'example'), '"dart $argString"'],
);

// flutter
expectLine(stdout, [
'flutter_puby_test',
'"flutter pub upgrade --major-versions"',
]);
expectLine(stdout, [
p.join('flutter_puby_test', 'example'),
'"flutter pub upgrade --major-versions"',
]);
expectLine(stdout, ['flutter_puby_test', '"flutter $argString"']);
expectLine(
stdout,
[p.join('flutter_puby_test', 'example'), '"flutter $argString"'],
);

// fvm
expectLine(stdout, [
'fvm_puby_test',
'"fvm flutter pub upgrade --major-versions"',
]);
expectLine(stdout, [
p.join('fvm_puby_test', 'example'),
'"fvm flutter pub upgrade --major-versions"',
]);
expectLine(stdout, ['fvm_puby_test', '"fvm flutter $argString"']);
expectLine(
stdout,
[p.join('fvm_puby_test', 'example'), '"fvm flutter $argString"'],
);
},
timeout: Timeout.factor(1.5),
);
Expand Down
23 changes: 15 additions & 8 deletions test/no_fvm_test.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import 'dart:io';

import 'package:test/test.dart';
import 'package:path/path.dart' as p;

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, 0);
expectLine(
stdout,
['fvm_puby_test', 'Project uses FVM, but FVM support is disabled'],
);
expectLine(stdout, ['fvm_puby_test', message]);
// Ensure the FVM Flutter version was not used
expect(
File('test_resources/fvm_puby_test/.dart_tool/version')
Expand All @@ -27,9 +27,16 @@ void main() {
final stdout = result.stdout;

expect(result.exitCode, 0);
expectLine(
stdout,
['fvm_puby_test', 'Project uses FVM, but FVM support is disabled'],
);
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, 0);
expectLine(stdout, ['fvm_puby_test', message]);
expectLine(stdout, [p.join('fvm_puby_test', 'example'), message]);
expectLine(stdout, [p.join('fvm_puby_test', 'nested'), message]);
});
}
4 changes: 4 additions & 0 deletions test/pub_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ void main() {
// 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']);
Expand Down
4 changes: 0 additions & 4 deletions test_resources/fvm_puby_test/example/.fvmrc

This file was deleted.

9 changes: 9 additions & 0 deletions test_resources/fvm_puby_test/nested/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: nested
publish_to: none

environment:
sdk: ^3.0.0

dependencies:
flutter:
sdk: flutter

0 comments on commit fbc1a17

Please sign in to comment.