Skip to content

Commit 97117bc

Browse files
authored
Merge pull request #33 from giginet/codex/fix-issue-31-and-improve-test-coverage
Fix case-sensitive path handling
2 parents efc812c + 7b5443e commit 97117bc

6 files changed

Lines changed: 29 additions & 9 deletions

File tree

__test__/arch_detector.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('ArchDetector', () => {
1212
})
1313

1414
it('should detect architectures from universal binary', async () => {
15-
const mockOutput = `.build/apple/Products/Release/myexecutable: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]
15+
const mockOutput = `.build/apple/Products/Release/myexecutable: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64]
1616
.build/apple/Products/Release/myexecutable (for architecture x86_64): Mach-O 64-bit executable x86_64
1717
.build/apple/Products/Release/myexecutable (for architecture arm64): Mach-O 64-bit executable arm64`
1818

__test__/executable_collector.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('ExecutableCollector', () => {
6060
})
6161

6262
it('should collect executables from apple directory with multiple architectures', async () => {
63-
const executablePath = '.build/apple/Products/release/myExecutable'
63+
const executablePath = '.build/apple/Products/Release/myExecutable'
6464
const mockGlobber = new MockGlobber()
6565
mockGlobber.glob.mockImplementation(() => {
6666
return Promise.resolve([executablePath])
@@ -82,6 +82,23 @@ describe('ExecutableCollector', () => {
8282
)
8383
})
8484

85+
it('should capitalize configuration for apple directory', async () => {
86+
const executablePath = '.build/apple/Products/Release/myExecutable'
87+
const mockGlobber = new MockGlobber()
88+
mockGlobber.glob.mockResolvedValue([executablePath])
89+
glob.create.mockResolvedValue(mockGlobber)
90+
jest
91+
.spyOn(ArchDetector.prototype, 'detectArch')
92+
.mockResolvedValue(['arm64'])
93+
94+
const collector = new ExecutableCollector('myExecutable')
95+
await collector.collect('release')
96+
97+
expect(glob.create).toHaveBeenCalledWith(
98+
expect.stringContaining('apple/Products/Release')
99+
)
100+
})
101+
85102
it('should return empty array when no executables found', async () => {
86103
const mockGlobber = new MockGlobber()
87104
mockGlobber.glob.mockImplementation(() => {

dist/index.js

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/arch_detector.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ export class ArchDetector {
2020
// First line contains the summary with all architectures
2121
const firstLine = lines[0]
2222
if (firstLine.includes('Mach-O universal binary')) {
23-
// Extract architectures from the first line, handling Linux format
24-
const archMatches = firstLine.match(/\[(?:\\012- )?(\w+):/g)
23+
// Extract architectures from the first line, handling cases like
24+
// "[x86_64:Mach-O 64-bit executable x86_64]" or "[arm64]"
25+
const archMatches = firstLine.match(/\[(?:\\012- )?(\w+)(?:[:\]])/g)
2526
if (archMatches) {
2627
archMatches.forEach((match) => {
27-
const arch = match.match(/(?:\\012- )?(\w+):/)?.[1]
28+
const arch = match.match(/\[(?:\\012- )?(\w+)(?:[:\]])/)?.[1]
2829
if (arch) {
2930
architectures.push(arch)
3031
}

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"$schema": "https://json.schemastore.org/tsconfig",
33
"extends": "./tsconfig.base.json",
4+
45
"compilerOptions": {
56
"module": "NodeNext",
67
"moduleResolution": "NodeNext",

0 commit comments

Comments
 (0)