From 131412784a715d4c912be5bce422e31042d4e176 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Dec 2025 03:45:38 +0000 Subject: [PATCH 1/9] Initial plan From 7bbb66e0ce73419cd0facb751d06eddc79d09efa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Dec 2025 03:52:38 +0000 Subject: [PATCH 2/9] Add comprehensive test coverage for version resolution Add tests for: - _dependenciesFromJson parsing in pubspec.dart (string versions, map versions, path/git dependencies, invalid versions, null dependencies, mixed formats) - Integration version constraint collection in config.dart (from pubspec.yaml and pubspec.lock) - Version resolution priority and edge cases Co-authored-by: AlexV525 <15884415+AlexV525@users.noreply.github.com> --- packages/core/test/config_test.dart | 217 +++++++++++++++++ packages/core/test/settings_test.dart | 227 ++++++++++++++++++ .../pubspec_integration_versions.lock | 29 +++ .../pubspec_integration_versions.yaml | 21 ++ ...pubspec_integration_versions_rive_014.lock | 21 ++ ...pubspec_integration_versions_rive_014.yaml | 18 ++ 6 files changed, 533 insertions(+) create mode 100644 packages/core/test/config_test.dart create mode 100644 packages/core/test_resources/pubspec_integration_versions.lock create mode 100644 packages/core/test_resources/pubspec_integration_versions.yaml create mode 100644 packages/core/test_resources/pubspec_integration_versions_rive_014.lock create mode 100644 packages/core/test_resources/pubspec_integration_versions_rive_014.yaml diff --git a/packages/core/test/config_test.dart b/packages/core/test/config_test.dart new file mode 100644 index 00000000..d8de16ff --- /dev/null +++ b/packages/core/test/config_test.dart @@ -0,0 +1,217 @@ +import 'dart:io'; + +import 'package:flutter_gen_core/generators/integrations/lottie_integration.dart'; +import 'package:flutter_gen_core/generators/integrations/rive_integration.dart'; +import 'package:flutter_gen_core/generators/integrations/svg_integration.dart'; +import 'package:flutter_gen_core/settings/config.dart'; +import 'package:pub_semver/pub_semver.dart'; +import 'package:test/test.dart'; + +void main() { + group('Config integration version resolution', () { + test('resolves versions from pubspec.lock', () { + final pubspecFile = File( + 'test_resources/pubspec_integration_versions.yaml', + ); + final config = loadPubspecConfig(pubspecFile); + + // Check that versions are resolved from pubspec.lock + expect( + config.integrationResolvedVersions[RiveIntegration], + equals(Version(0, 13, 5)), + ); + expect( + config.integrationResolvedVersions[SvgIntegration], + equals(Version(2, 0, 9)), + ); + expect( + config.integrationResolvedVersions[LottieIntegration], + equals(Version(5, 1, 0)), + ); + }); + + test('resolves version constraints from pubspec.yaml', () { + final pubspecFile = File( + 'test_resources/pubspec_integration_versions.yaml', + ); + final config = loadPubspecConfig(pubspecFile); + + // Check that constraints are resolved from pubspec.yaml + expect( + config.integrationVersionConstraints[RiveIntegration], + equals(VersionConstraint.parse('^0.13.0')), + ); + expect( + config.integrationVersionConstraints[SvgIntegration], + equals(VersionConstraint.parse('^2.0.0')), + ); + expect( + config.integrationVersionConstraints[LottieIntegration], + equals(VersionConstraint.parse('^5.0.0')), + ); + }); + + test('resolves Rive 0.14.0 versions correctly', () { + final pubspecFile = File( + 'test_resources/pubspec_integration_versions_rive_014.yaml', + ); + final config = loadPubspecConfig(pubspecFile); + + // Check that Rive 0.14.0+ version is resolved + expect( + config.integrationResolvedVersions[RiveIntegration], + equals(Version(0, 14, 1)), + ); + expect( + config.integrationVersionConstraints[RiveIntegration], + equals(VersionConstraint.parse('^0.14.0')), + ); + + // Check that flutter_svg is also resolved + expect( + config.integrationResolvedVersions[SvgIntegration], + equals(Version(2, 0, 10)), + ); + expect( + config.integrationVersionConstraints[SvgIntegration], + equals(VersionConstraint.parse('>=2.0.0 <3.0.0')), + ); + }); + + test('handles missing pubspec.lock gracefully', () { + // Use a pubspec without a corresponding .lock file + final pubspecFile = File( + 'test_resources/pubspec_assets_rive_integrations.yaml', + ); + final config = loadPubspecConfig(pubspecFile); + + // Should have empty or no resolved versions + // but should not crash + expect(config, isNotNull); + expect(config.integrationResolvedVersions, isA()); + expect(config.integrationVersionConstraints, isA()); + }); + + test('handles dependencies without version constraints', () { + final pubspecFile = File( + 'test_resources/pubspec_integration_versions.yaml', + ); + final config = loadPubspecConfig(pubspecFile); + + // Packages not in dependencies should not be in the maps + expect( + config.integrationVersionConstraints.containsKey(null), + isFalse, + ); + }); + + test('integration versions are used in AssetsGenConfig', () { + final pubspecFile = File( + 'test_resources/pubspec_integration_versions.yaml', + ); + final config = loadPubspecConfig(pubspecFile); + + // Verify that the resolved versions and constraints are available + expect(config.integrationResolvedVersions, isNotEmpty); + expect(config.integrationVersionConstraints, isNotEmpty); + + // Verify they can be passed to generators + expect( + config.integrationResolvedVersions[RiveIntegration], + isA(), + ); + expect( + config.integrationVersionConstraints[RiveIntegration], + isA(), + ); + }); + + test('version resolution with only constraint and no lock', () { + // Create a temporary pubspec file without a lock + final tempDir = Directory.systemTemp.createTempSync('flutter_gen_test'); + try { + final tempPubspec = File('${tempDir.path}/pubspec.yaml'); + tempPubspec.writeAsStringSync(''' +name: test_no_lock +environment: + sdk: ^3.0.0 +dependencies: + rive: ^0.13.0 +flutter_gen: + output: lib/gen/ + integrations: + rive: true +flutter: + assets: + - assets/ +'''); + + final config = loadPubspecConfig(tempPubspec); + + // Should have constraint but no resolved version + expect( + config.integrationVersionConstraints[RiveIntegration], + equals(VersionConstraint.parse('^0.13.0')), + ); + expect( + config.integrationResolvedVersions[RiveIntegration], + isNull, + ); + } finally { + tempDir.deleteSync(recursive: true); + } + }); + + test('version resolution with lock but no constraint', () { + // This tests the case where pubspec.lock has a version + // but pubspec.yaml doesn't specify a constraint (e.g., path dependency) + final tempDir = Directory.systemTemp.createTempSync('flutter_gen_test'); + try { + final tempPubspec = File('${tempDir.path}/pubspec.yaml'); + tempPubspec.writeAsStringSync(''' +name: test_lock_only +environment: + sdk: ^3.0.0 +dependencies: + rive: + path: ../rive +flutter_gen: + output: lib/gen/ + integrations: + rive: true +flutter: + assets: + - assets/ +'''); + + final tempLock = File('${tempDir.path}/pubspec.lock'); + tempLock.writeAsStringSync(''' +packages: + rive: + dependency: "direct main" + description: + path: "../rive" + relative: true + source: path + version: "0.13.5" +sdks: + dart: ">=3.0.0 <4.0.0" +'''); + + final config = loadPubspecConfig(tempPubspec); + + // Should have resolved version but no constraint + expect( + config.integrationResolvedVersions[RiveIntegration], + equals(Version(0, 13, 5)), + ); + expect( + config.integrationVersionConstraints[RiveIntegration], + isNull, + ); + } finally { + tempDir.deleteSync(recursive: true); + } + }); + }); +} diff --git a/packages/core/test/settings_test.dart b/packages/core/test/settings_test.dart index 3629b1f4..b2a32b2c 100644 --- a/packages/core/test/settings_test.dart +++ b/packages/core/test/settings_test.dart @@ -4,7 +4,9 @@ import 'package:flutter_gen_core/settings/flavored_asset.dart'; import 'package:flutter_gen_core/settings/pubspec.dart'; import 'package:flutter_gen_core/utils/error.dart' show InvalidSettingsException; +import 'package:pub_semver/pub_semver.dart'; import 'package:test/test.dart'; +import 'package:yaml/yaml.dart'; void main() { group(AssetType, () { @@ -116,4 +118,229 @@ void main() { ); }); }); + + group('Pubspec.dependenciesVersionConstraint', () { + test('parses string version constraints', () { + final yaml = loadYaml(''' +name: test +environment: + sdk: ^3.0.0 +dependencies: + rive: ^0.13.0 + flutter_svg: ^2.0.0 + lottie: ">=1.0.0 <2.0.0" +flutter_gen: + output: lib/gen/ +flutter: + assets: + - assets/ +'''); + final pubspec = Pubspec.fromJson(yaml); + + expect(pubspec.dependenciesVersionConstraint['rive'], isNotNull); + expect( + pubspec.dependenciesVersionConstraint['rive'], + equals(VersionConstraint.parse('^0.13.0')), + ); + + expect(pubspec.dependenciesVersionConstraint['flutter_svg'], isNotNull); + expect( + pubspec.dependenciesVersionConstraint['flutter_svg'], + equals(VersionConstraint.parse('^2.0.0')), + ); + + expect(pubspec.dependenciesVersionConstraint['lottie'], isNotNull); + expect( + pubspec.dependenciesVersionConstraint['lottie'], + equals(VersionConstraint.parse('>=1.0.0 <2.0.0')), + ); + }); + + test('parses map with version key', () { + final yaml = loadYaml(''' +name: test +environment: + sdk: ^3.0.0 +dependencies: + rive: + version: ^0.14.0 + flutter_svg: + version: ">=2.0.0 <3.0.0" +flutter_gen: + output: lib/gen/ +flutter: + assets: + - assets/ +'''); + final pubspec = Pubspec.fromJson(yaml); + + expect(pubspec.dependenciesVersionConstraint['rive'], isNotNull); + expect( + pubspec.dependenciesVersionConstraint['rive'], + equals(VersionConstraint.parse('^0.14.0')), + ); + + expect(pubspec.dependenciesVersionConstraint['flutter_svg'], isNotNull); + expect( + pubspec.dependenciesVersionConstraint['flutter_svg'], + equals(VersionConstraint.parse('>=2.0.0 <3.0.0')), + ); + }); + + test('handles path dependencies without version', () { + final yaml = loadYaml(''' +name: test +environment: + sdk: ^3.0.0 +dependencies: + rive: + path: ../rive + flutter_svg: ^2.0.0 +flutter_gen: + output: lib/gen/ +flutter: + assets: + - assets/ +'''); + final pubspec = Pubspec.fromJson(yaml); + + // Path dependency should be null since no version constraint + expect(pubspec.dependenciesVersionConstraint['rive'], isNull); + + // String version should still work + expect(pubspec.dependenciesVersionConstraint['flutter_svg'], isNotNull); + expect( + pubspec.dependenciesVersionConstraint['flutter_svg'], + equals(VersionConstraint.parse('^2.0.0')), + ); + }); + + test('handles git dependencies without version', () { + final yaml = loadYaml(''' +name: test +environment: + sdk: ^3.0.0 +dependencies: + rive: + git: + url: https://github.com/example/rive.git + ref: main + lottie: ^5.0.0 +flutter_gen: + output: lib/gen/ +flutter: + assets: + - assets/ +'''); + final pubspec = Pubspec.fromJson(yaml); + + // Git dependency should be null since no version constraint + expect(pubspec.dependenciesVersionConstraint['rive'], isNull); + + // String version should still work + expect(pubspec.dependenciesVersionConstraint['lottie'], isNotNull); + expect( + pubspec.dependenciesVersionConstraint['lottie'], + equals(VersionConstraint.parse('^5.0.0')), + ); + }); + + test('handles invalid version strings gracefully', () { + final yaml = loadYaml(''' +name: test +environment: + sdk: ^3.0.0 +dependencies: + rive: invalid_version + flutter_svg: ^2.0.0 +flutter_gen: + output: lib/gen/ +flutter: + assets: + - assets/ +'''); + final pubspec = Pubspec.fromJson(yaml); + + // Invalid version should be null + expect(pubspec.dependenciesVersionConstraint['rive'], isNull); + + // Valid version should work + expect(pubspec.dependenciesVersionConstraint['flutter_svg'], isNotNull); + }); + + test('handles dependencies with version key containing invalid version', () { + final yaml = loadYaml(''' +name: test +environment: + sdk: ^3.0.0 +dependencies: + rive: + version: invalid_version + lottie: ^5.0.0 +flutter_gen: + output: lib/gen/ +flutter: + assets: + - assets/ +'''); + final pubspec = Pubspec.fromJson(yaml); + + // Invalid version in map should be null + expect(pubspec.dependenciesVersionConstraint['rive'], isNull); + + // Valid string version should work + expect(pubspec.dependenciesVersionConstraint['lottie'], isNotNull); + }); + + test('handles null dependencies', () { + final yaml = loadYaml(''' +name: test +environment: + sdk: ^3.0.0 +flutter_gen: + output: lib/gen/ +flutter: + assets: + - assets/ +'''); + final pubspec = Pubspec.fromJson(yaml); + + // Should return empty map for null dependencies + expect(pubspec.dependenciesVersionConstraint, isEmpty); + }); + + test('handles mixed dependency formats', () { + final yaml = loadYaml(''' +name: test +environment: + sdk: ^3.0.0 +dependencies: + rive: ^0.13.0 + flutter_svg: + version: ^2.0.0 + lottie: + path: ../lottie + another_package: + git: + url: https://github.com/example/package.git +flutter_gen: + output: lib/gen/ +flutter: + assets: + - assets/ +'''); + final pubspec = Pubspec.fromJson(yaml); + + expect( + pubspec.dependenciesVersionConstraint['rive'], + equals(VersionConstraint.parse('^0.13.0')), + ); + expect( + pubspec.dependenciesVersionConstraint['flutter_svg'], + equals(VersionConstraint.parse('^2.0.0')), + ); + expect(pubspec.dependenciesVersionConstraint['lottie'], isNull); + expect(pubspec.dependenciesVersionConstraint['another_package'], isNull); + }); + }); } diff --git a/packages/core/test_resources/pubspec_integration_versions.lock b/packages/core/test_resources/pubspec_integration_versions.lock new file mode 100644 index 00000000..e2f8a807 --- /dev/null +++ b/packages/core/test_resources/pubspec_integration_versions.lock @@ -0,0 +1,29 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + rive: + dependency: "direct main" + description: + name: rive + sha256: "abc123" + url: "https://pub.dev" + source: hosted + version: "0.13.5" + flutter_svg: + dependency: "direct main" + description: + name: flutter_svg + sha256: "def456" + url: "https://pub.dev" + source: hosted + version: "2.0.9" + lottie: + dependency: "direct main" + description: + name: lottie + sha256: "ghi789" + url: "https://pub.dev" + source: hosted + version: "5.1.0" +sdks: + dart: ">=3.0.0 <4.0.0" diff --git a/packages/core/test_resources/pubspec_integration_versions.yaml b/packages/core/test_resources/pubspec_integration_versions.yaml new file mode 100644 index 00000000..222cb0f9 --- /dev/null +++ b/packages/core/test_resources/pubspec_integration_versions.yaml @@ -0,0 +1,21 @@ +name: test_integration_versions + +environment: + sdk: ^3.0.0 + +dependencies: + rive: ^0.13.0 + flutter_svg: ^2.0.0 + lottie: + version: ^5.0.0 + +flutter_gen: + output: lib/gen/ + integrations: + rive: true + flutter_svg: true + lottie: true + +flutter: + assets: + - assets/ diff --git a/packages/core/test_resources/pubspec_integration_versions_rive_014.lock b/packages/core/test_resources/pubspec_integration_versions_rive_014.lock new file mode 100644 index 00000000..8009d48b --- /dev/null +++ b/packages/core/test_resources/pubspec_integration_versions_rive_014.lock @@ -0,0 +1,21 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + rive: + dependency: "direct main" + description: + name: rive + sha256: "xyz123" + url: "https://pub.dev" + source: hosted + version: "0.14.1" + flutter_svg: + dependency: "direct main" + description: + name: flutter_svg + sha256: "uvw456" + url: "https://pub.dev" + source: hosted + version: "2.0.10" +sdks: + dart: ">=3.0.0 <4.0.0" diff --git a/packages/core/test_resources/pubspec_integration_versions_rive_014.yaml b/packages/core/test_resources/pubspec_integration_versions_rive_014.yaml new file mode 100644 index 00000000..7bd8c58d --- /dev/null +++ b/packages/core/test_resources/pubspec_integration_versions_rive_014.yaml @@ -0,0 +1,18 @@ +name: test_integration_versions_rive_014 + +environment: + sdk: ^3.0.0 + +dependencies: + rive: ^0.14.0 + flutter_svg: ">=2.0.0 <3.0.0" + +flutter_gen: + output: lib/gen/ + integrations: + rive: true + flutter_svg: true + +flutter: + assets: + - assets/ From 45a3991034a7bec0142d90eaf439db1758fe7437 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Dec 2025 03:53:45 +0000 Subject: [PATCH 3/9] Add integration tests for version resolution in assets generator Test version resolution with various constraint formats and validate the integration with AssetsGenConfig Co-authored-by: AlexV525 <15884415+AlexV525@users.noreply.github.com> --- .../test/assets_gen_integrations_test.dart | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/packages/core/test/assets_gen_integrations_test.dart b/packages/core/test/assets_gen_integrations_test.dart index dd397d7e..4e4ba454 100644 --- a/packages/core/test/assets_gen_integrations_test.dart +++ b/packages/core/test/assets_gen_integrations_test.dart @@ -459,5 +459,77 @@ void main() { isTrue, ); }); + + test('Integration version resolution in AssetsGenConfig', () { + // Test that version resolution is properly integrated into assets generation + // This validates the full flow from config loading to integration creation + + // Create a RiveIntegration with both resolved version and constraint + final integrationWithBoth = RiveIntegration( + '', + resolvedVersion: Version(0, 13, 0), + resolvedVersionConstraint: VersionConstraint.parse('^0.14.0'), + ); + // Should prefer resolvedVersion over resolvedVersionConstraint + expect(integrationWithBoth, isA()); + + // Create a RiveIntegration with only resolvedVersion + final integrationVersionOnly = RiveIntegration( + '', + resolvedVersion: Version(0, 14, 0), + ); + expect(integrationVersionOnly, isA()); + + // Create a RiveIntegration with only resolvedVersionConstraint + final integrationConstraintOnly = RiveIntegration( + '', + resolvedVersionConstraint: VersionConstraint.parse('^0.14.0'), + ); + expect(integrationConstraintOnly, isA()); + }); + + test('Version resolution with various constraint formats', () { + // Test with ^0.13.x constraint (should use Classic) + final caretOld = RiveIntegration( + '', + resolvedVersionConstraint: VersionConstraint.parse('^0.13.5'), + ); + expect(caretOld, isA()); + + // Test with ^0.14.x constraint (should use 0140) + final caretNew = RiveIntegration( + '', + resolvedVersionConstraint: VersionConstraint.parse('^0.14.1'), + ); + expect(caretNew, isA()); + + // Test with >= constraint that includes 0.14.0 + final rangeIncludesNew = RiveIntegration( + '', + resolvedVersionConstraint: VersionConstraint.parse('>=0.13.0 <1.0.0'), + ); + expect(rangeIncludesNew, isA()); + + // Test with >= constraint that excludes 0.14.0 + final rangeExcludesNew = RiveIntegration( + '', + resolvedVersionConstraint: VersionConstraint.parse('>=0.13.0 <0.14.0'), + ); + expect(rangeExcludesNew, isA()); + + // Test with exact version < 0.14.0 + final exactOld = RiveIntegration( + '', + resolvedVersion: Version(0, 13, 99), + ); + expect(exactOld, isA()); + + // Test with exact version >= 0.14.0 + final exactNew = RiveIntegration( + '', + resolvedVersion: Version(0, 14, 0), + ); + expect(exactNew, isA()); + }); }); } From 6ebe3fba88ab5544b978241430f0dee5724e93dc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Dec 2025 03:55:26 +0000 Subject: [PATCH 4/9] Fix test issues from code review - Replace meaningless null key check with proper validation of expected integration types - Clarify comment about version resolution priority Co-authored-by: AlexV525 <15884415+AlexV525@users.noreply.github.com> --- .../test/assets_gen_integrations_test.dart | 4 +++- packages/core/test/config_test.dart | 23 ++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/packages/core/test/assets_gen_integrations_test.dart b/packages/core/test/assets_gen_integrations_test.dart index 4e4ba454..e96b7bf2 100644 --- a/packages/core/test/assets_gen_integrations_test.dart +++ b/packages/core/test/assets_gen_integrations_test.dart @@ -465,12 +465,14 @@ void main() { // This validates the full flow from config loading to integration creation // Create a RiveIntegration with both resolved version and constraint + // When resolvedVersion is 0.13.0 (< 0.14.0), it should use Classic + // even if resolvedVersionConstraint would allow 0.14.0 final integrationWithBoth = RiveIntegration( '', resolvedVersion: Version(0, 13, 0), resolvedVersionConstraint: VersionConstraint.parse('^0.14.0'), ); - // Should prefer resolvedVersion over resolvedVersionConstraint + // resolvedVersion takes priority: 0.13.0 < 0.14.0 => Classic expect(integrationWithBoth, isA()); // Create a RiveIntegration with only resolvedVersion diff --git a/packages/core/test/config_test.dart b/packages/core/test/config_test.dart index d8de16ff..7f8666c3 100644 --- a/packages/core/test/config_test.dart +++ b/packages/core/test/config_test.dart @@ -92,17 +92,28 @@ void main() { expect(config.integrationVersionConstraints, isA()); }); - test('handles dependencies without version constraints', () { + test('verifies only expected integration types are present', () { final pubspecFile = File( 'test_resources/pubspec_integration_versions.yaml', ); final config = loadPubspecConfig(pubspecFile); - // Packages not in dependencies should not be in the maps - expect( - config.integrationVersionConstraints.containsKey(null), - isFalse, - ); + // Verify that only integration types from the registry are in the maps + for (final key in config.integrationVersionConstraints.keys) { + expect( + [RiveIntegration, SvgIntegration, LottieIntegration].contains(key), + isTrue, + reason: 'Unexpected integration type: $key', + ); + } + + for (final key in config.integrationResolvedVersions.keys) { + expect( + [RiveIntegration, SvgIntegration, LottieIntegration].contains(key), + isTrue, + reason: 'Unexpected integration type: $key', + ); + } }); test('integration versions are used in AssetsGenConfig', () { From c0986b4daa40663f277b7096d166a1b1df6c76cd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Dec 2025 03:57:07 +0000 Subject: [PATCH 5/9] Improve test maintainability based on code review - Use consistent dependency format in test resources - Import and use integrationPackages registry instead of hardcoding types Co-authored-by: AlexV525 <15884415+AlexV525@users.noreply.github.com> --- packages/core/test/config_test.dart | 7 +++++-- .../core/test_resources/pubspec_integration_versions.yaml | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/core/test/config_test.dart b/packages/core/test/config_test.dart index 7f8666c3..7cdfab68 100644 --- a/packages/core/test/config_test.dart +++ b/packages/core/test/config_test.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter_gen_core/generators/integrations/lottie_integration.dart'; import 'package:flutter_gen_core/generators/integrations/rive_integration.dart'; import 'package:flutter_gen_core/generators/integrations/svg_integration.dart'; +import 'package:flutter_gen_core/generators/registry.dart'; import 'package:flutter_gen_core/settings/config.dart'; import 'package:pub_semver/pub_semver.dart'; import 'package:test/test.dart'; @@ -99,9 +100,11 @@ void main() { final config = loadPubspecConfig(pubspecFile); // Verify that only integration types from the registry are in the maps + final expectedTypes = integrationPackages.keys.toList(); + for (final key in config.integrationVersionConstraints.keys) { expect( - [RiveIntegration, SvgIntegration, LottieIntegration].contains(key), + expectedTypes.contains(key), isTrue, reason: 'Unexpected integration type: $key', ); @@ -109,7 +112,7 @@ void main() { for (final key in config.integrationResolvedVersions.keys) { expect( - [RiveIntegration, SvgIntegration, LottieIntegration].contains(key), + expectedTypes.contains(key), isTrue, reason: 'Unexpected integration type: $key', ); diff --git a/packages/core/test_resources/pubspec_integration_versions.yaml b/packages/core/test_resources/pubspec_integration_versions.yaml index 222cb0f9..fecd6e60 100644 --- a/packages/core/test_resources/pubspec_integration_versions.yaml +++ b/packages/core/test_resources/pubspec_integration_versions.yaml @@ -6,8 +6,7 @@ environment: dependencies: rive: ^0.13.0 flutter_svg: ^2.0.0 - lottie: - version: ^5.0.0 + lottie: ^5.0.0 flutter_gen: output: lib/gen/ From 3d8146a33ba6949042f6420193031367a54b4c94 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Dec 2025 04:15:37 +0000 Subject: [PATCH 6/9] Fix test resource paths to follow pubspec.lock naming convention Moved test resources into subdirectories with standard pubspec.yaml/pubspec.lock names. This fixes the issue where loadPubspecConfig expects pubspec.lock in the same directory as pubspec.yaml, not with custom names. Co-authored-by: AlexV525 <15884415+AlexV525@users.noreply.github.com> --- packages/core/test/config_test.dart | 10 +++---- .../pubspec.yaml} | 0 .../pubspec.yaml} | 0 .../pubspec_integration_versions.lock | 29 ------------------- ...pubspec_integration_versions_rive_014.lock | 21 -------------- 5 files changed, 5 insertions(+), 55 deletions(-) rename packages/core/test_resources/{pubspec_integration_versions.yaml => integration_versions/pubspec.yaml} (100%) rename packages/core/test_resources/{pubspec_integration_versions_rive_014.yaml => integration_versions_rive_014/pubspec.yaml} (100%) delete mode 100644 packages/core/test_resources/pubspec_integration_versions.lock delete mode 100644 packages/core/test_resources/pubspec_integration_versions_rive_014.lock diff --git a/packages/core/test/config_test.dart b/packages/core/test/config_test.dart index 7cdfab68..7f4baabb 100644 --- a/packages/core/test/config_test.dart +++ b/packages/core/test/config_test.dart @@ -12,7 +12,7 @@ void main() { group('Config integration version resolution', () { test('resolves versions from pubspec.lock', () { final pubspecFile = File( - 'test_resources/pubspec_integration_versions.yaml', + 'test_resources/integration_versions/pubspec.yaml', ); final config = loadPubspecConfig(pubspecFile); @@ -33,7 +33,7 @@ void main() { test('resolves version constraints from pubspec.yaml', () { final pubspecFile = File( - 'test_resources/pubspec_integration_versions.yaml', + 'test_resources/integration_versions/pubspec.yaml', ); final config = loadPubspecConfig(pubspecFile); @@ -54,7 +54,7 @@ void main() { test('resolves Rive 0.14.0 versions correctly', () { final pubspecFile = File( - 'test_resources/pubspec_integration_versions_rive_014.yaml', + 'test_resources/integration_versions_rive_014/pubspec.yaml', ); final config = loadPubspecConfig(pubspecFile); @@ -95,7 +95,7 @@ void main() { test('verifies only expected integration types are present', () { final pubspecFile = File( - 'test_resources/pubspec_integration_versions.yaml', + 'test_resources/integration_versions/pubspec.yaml', ); final config = loadPubspecConfig(pubspecFile); @@ -121,7 +121,7 @@ void main() { test('integration versions are used in AssetsGenConfig', () { final pubspecFile = File( - 'test_resources/pubspec_integration_versions.yaml', + 'test_resources/integration_versions/pubspec.yaml', ); final config = loadPubspecConfig(pubspecFile); diff --git a/packages/core/test_resources/pubspec_integration_versions.yaml b/packages/core/test_resources/integration_versions/pubspec.yaml similarity index 100% rename from packages/core/test_resources/pubspec_integration_versions.yaml rename to packages/core/test_resources/integration_versions/pubspec.yaml diff --git a/packages/core/test_resources/pubspec_integration_versions_rive_014.yaml b/packages/core/test_resources/integration_versions_rive_014/pubspec.yaml similarity index 100% rename from packages/core/test_resources/pubspec_integration_versions_rive_014.yaml rename to packages/core/test_resources/integration_versions_rive_014/pubspec.yaml diff --git a/packages/core/test_resources/pubspec_integration_versions.lock b/packages/core/test_resources/pubspec_integration_versions.lock deleted file mode 100644 index e2f8a807..00000000 --- a/packages/core/test_resources/pubspec_integration_versions.lock +++ /dev/null @@ -1,29 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - rive: - dependency: "direct main" - description: - name: rive - sha256: "abc123" - url: "https://pub.dev" - source: hosted - version: "0.13.5" - flutter_svg: - dependency: "direct main" - description: - name: flutter_svg - sha256: "def456" - url: "https://pub.dev" - source: hosted - version: "2.0.9" - lottie: - dependency: "direct main" - description: - name: lottie - sha256: "ghi789" - url: "https://pub.dev" - source: hosted - version: "5.1.0" -sdks: - dart: ">=3.0.0 <4.0.0" diff --git a/packages/core/test_resources/pubspec_integration_versions_rive_014.lock b/packages/core/test_resources/pubspec_integration_versions_rive_014.lock deleted file mode 100644 index 8009d48b..00000000 --- a/packages/core/test_resources/pubspec_integration_versions_rive_014.lock +++ /dev/null @@ -1,21 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - rive: - dependency: "direct main" - description: - name: rive - sha256: "xyz123" - url: "https://pub.dev" - source: hosted - version: "0.14.1" - flutter_svg: - dependency: "direct main" - description: - name: flutter_svg - sha256: "uvw456" - url: "https://pub.dev" - source: hosted - version: "2.0.10" -sdks: - dart: ">=3.0.0 <4.0.0" From 757f0ef0e15f1a900ace3d122c5ae6685bd7962f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Dec 2025 04:16:21 +0000 Subject: [PATCH 7/9] Add pubspec.lock files for integration version tests Force-add the lock files that were excluded by gitignore. These test resources need lock files to test version resolution. Co-authored-by: AlexV525 <15884415+AlexV525@users.noreply.github.com> --- .../integration_versions/pubspec.lock | 29 +++++++++++++++++++ .../pubspec.lock | 21 ++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 packages/core/test_resources/integration_versions/pubspec.lock create mode 100644 packages/core/test_resources/integration_versions_rive_014/pubspec.lock diff --git a/packages/core/test_resources/integration_versions/pubspec.lock b/packages/core/test_resources/integration_versions/pubspec.lock new file mode 100644 index 00000000..e2f8a807 --- /dev/null +++ b/packages/core/test_resources/integration_versions/pubspec.lock @@ -0,0 +1,29 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + rive: + dependency: "direct main" + description: + name: rive + sha256: "abc123" + url: "https://pub.dev" + source: hosted + version: "0.13.5" + flutter_svg: + dependency: "direct main" + description: + name: flutter_svg + sha256: "def456" + url: "https://pub.dev" + source: hosted + version: "2.0.9" + lottie: + dependency: "direct main" + description: + name: lottie + sha256: "ghi789" + url: "https://pub.dev" + source: hosted + version: "5.1.0" +sdks: + dart: ">=3.0.0 <4.0.0" diff --git a/packages/core/test_resources/integration_versions_rive_014/pubspec.lock b/packages/core/test_resources/integration_versions_rive_014/pubspec.lock new file mode 100644 index 00000000..8009d48b --- /dev/null +++ b/packages/core/test_resources/integration_versions_rive_014/pubspec.lock @@ -0,0 +1,21 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + rive: + dependency: "direct main" + description: + name: rive + sha256: "xyz123" + url: "https://pub.dev" + source: hosted + version: "0.14.1" + flutter_svg: + dependency: "direct main" + description: + name: flutter_svg + sha256: "uvw456" + url: "https://pub.dev" + source: hosted + version: "2.0.10" +sdks: + dart: ">=3.0.0 <4.0.0" From f02b25252c83364c53454e0990e7b006c693a1eb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Dec 2025 04:18:54 +0000 Subject: [PATCH 8/9] Fix pubspec.lock path resolution to use full parent path Changed from basename(pubspecFile.parent.path) to pubspecFile.parent.path to correctly resolve pubspec.lock location. The basename() call was stripping directory structure, causing lock files in subdirectories to not be found. Co-authored-by: AlexV525 <15884415+AlexV525@users.noreply.github.com> --- packages/core/lib/settings/config.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/lib/settings/config.dart b/packages/core/lib/settings/config.dart index 68cacd18..7a0fe25b 100644 --- a/packages/core/lib/settings/config.dart +++ b/packages/core/lib/settings/config.dart @@ -105,7 +105,7 @@ Config loadPubspecConfig(File pubspecFile, {File? buildFile}) { final pubspec = Pubspec.fromJson(mergedMap); final pubspecLockFile = File( - normalize(join(basename(pubspecFile.parent.path), 'pubspec.lock')), + normalize(join(pubspecFile.parent.path, 'pubspec.lock')), ); final pubspecLockContent = switch (pubspecLockFile.existsSync()) { true => pubspecLockFile.readAsStringSync(), From 7f88429a001fd4402940b671eb10c788be944ba4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Dec 2025 04:19:19 +0000 Subject: [PATCH 9/9] Fix analysis_options.yaml path resolution Apply same fix to analysis_options.yaml path - use full parent path instead of basename to correctly locate the file. Co-authored-by: AlexV525 <15884415+AlexV525@users.noreply.github.com> --- packages/core/lib/settings/config.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/lib/settings/config.dart b/packages/core/lib/settings/config.dart index 7a0fe25b..682787c0 100644 --- a/packages/core/lib/settings/config.dart +++ b/packages/core/lib/settings/config.dart @@ -130,7 +130,7 @@ Config loadPubspecConfig(File pubspecFile, {File? buildFile}) { } final analysisOptionsFile = File( - normalize(join(basename(pubspecFile.parent.path), 'analysis_options.yaml')), + normalize(join(pubspecFile.parent.path, 'analysis_options.yaml')), ); final analysisOptionsContent = switch (analysisOptionsFile.existsSync()) { true => analysisOptionsFile.readAsStringSync(),