Skip to content

Add test coverage for duplicate license file prevention#39

Closed
Copilot wants to merge 4 commits into
feature/bug-fixes-and-testsfrom
copilot/sub-pr-31-again
Closed

Add test coverage for duplicate license file prevention#39
Copilot wants to merge 4 commits into
feature/bug-fixes-and-testsfrom
copilot/sub-pr-31-again

Conversation

Copilot AI commented Feb 7, 2026

Copy link
Copy Markdown
Contributor

Addresses review feedback requesting tests for the break statement added in a0ea75c that prevents duplicate acknowledgements when packages contain multiple license files (LICENSE, LICENSE.txt, LICENSE.md).

Changes

  • DuplicateLicenseFileTests.swift: Three test cases validating the fix:

    • Single package with multiple license files → one acknowledgement using first match (LICENSE)
    • Multiple packages with varying license files → one acknowledgement per package, correct priority
    • Explicit test demonstrating bug without break → duplicate entries created
  • scanForLicenses(shouldBreak:): Helper method simulating CLI scanning logic using temporary SPM checkout directories, tests both correct and buggy behavior paths

Test Approach

// Given: Package with LICENSE, LICENSE.txt, LICENSE.md
let packageDir = packageCachePath.appendingPathComponent("TestPackage")
try createLicenseFiles(in: packageDir)

// When: Scanning with break (correct behavior)
let acknowledgements = try scanForLicenses(shouldBreak: true)

// Then: Only one entry, uses first match
XCTAssertEqual(acknowledgements.count, 1)
XCTAssertEqual(acknowledgements[0].license, licenseFromLICENSE)

Tests compile on Linux but require macOS to run (SwiftUI dependency in package).


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 7, 2026 04:23
- Add AckGenCLI dependency to test target
- Create DuplicateLicenseFileTests.swift with 4 comprehensive tests
- Tests verify that break statement prevents duplicate acknowledgements
- Tests simulate SPM checkout directory structure with multiple license files

Co-authored-by: MartinP7r <2669027+MartinP7r@users.noreply.github.com>
The tests only use AckGenCore types and simulate CLI logic inline,
so the AckGenCLI dependency is not needed.

Co-authored-by: MartinP7r <2669027+MartinP7r@users.noreply.github.com>
- Extract scanning logic into scanForLicenses helper method
- Rename 'fman' to 'fileManager' for clarity
- Add shouldBreak parameter to test both correct and buggy behavior
- Reduces code duplication across test methods

Co-authored-by: MartinP7r <2669027+MartinP7r@users.noreply.github.com>
Copilot AI changed the title [WIP] Add a test for SwiftArgumentParser migration changes Add test coverage for duplicate license file prevention Feb 7, 2026
Copilot AI requested a review from MartinP7r February 7, 2026 04:27
MartinP7r added a commit that referenced this pull request Mar 8, 2026
Verifies that only one acknowledgement is created per package when
multiple license file variants exist (LICENSE, LICENSE.txt, LICENSE.md).

Closes #39
@MartinP7r

Copy link
Copy Markdown
Owner

Closing in favor of #42 which applies these tests rebased onto current main. Cleaned up slightly (removed redundant comments, simplified helper). All tests pass.

@MartinP7r MartinP7r closed this Mar 8, 2026
MartinP7r added a commit that referenced this pull request Mar 8, 2026
Verifies that only one acknowledgement is created per package when
multiple license file variants exist (LICENSE, LICENSE.txt, LICENSE.md).

Closes #39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants