Skip to content

Commit 0b00a5c

Browse files
committed
chore: wip
1 parent 7178398 commit 0b00a5c

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

packages/launchpad/test/performance-optimizations.test.ts

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,21 @@ describe('Performance Optimizations', () => {
121121
const generatedShellCode = shellcode()
122122

123123
// Fast path should return 0 immediately when conditions are met
124-
const fastPathSection = generatedShellCode.substring(
125-
generatedShellCode.indexOf('If environment exists and has binaries, activate quickly'),
126-
generatedShellCode.indexOf('Skip setup if we\'ve had too many timeouts'),
127-
)
124+
// Look for the ultra-fast path activation logic
125+
expect(generatedShellCode).toContain('Ultra-fast path activation completed')
126+
expect(generatedShellCode).toContain('return 0')
128127

129-
expect(fastPathSection).toContain('return 0')
128+
// Should have instant activation logic
129+
expect(generatedShellCode).toContain('Instant activation - no external commands, no file operations')
130130
})
131131

132132
it('should include optimized binary existence check', () => {
133133
const generatedShellCode = shellcode()
134134

135-
// Should use glob expansion which is faster than ls
136-
expect(generatedShellCode).toContain('use glob expansion which is faster than ls')
137-
expect(generatedShellCode).toContain('$(echo "$env_dir/bin"/*)')
138-
expect(generatedShellCode).toContain('!= "$env_dir/bin/*"')
135+
// Should have directory existence checks for fast path
136+
expect(generatedShellCode).toContain('-d "$env_dir/bin"')
137+
expect(generatedShellCode).toContain('Ultra-fast path')
138+
expect(generatedShellCode).toContain('ready=true')
139139
})
140140

141141
it('should use optimized printf instead of slow commands in fast path', () => {
@@ -144,8 +144,8 @@ describe('Performance Optimizations', () => {
144144
// Should use printf for activation messages
145145
expect(generatedShellCode).toContain('printf "✅ Environment activated')
146146

147-
// Should have the basic fast path logic
148-
expect(generatedShellCode).toContain('If environment exists and has binaries, activate quickly')
147+
// Should have fast path logic with return 0
148+
expect(generatedShellCode).toContain('Ultra-fast path')
149149
expect(generatedShellCode).toContain('return 0')
150150
})
151151
})
@@ -218,19 +218,16 @@ describe('Performance Optimizations', () => {
218218
it('should minimize filesystem operations in fast path', () => {
219219
const generatedShellCode = shellcode()
220220

221-
// The fast path should have minimal filesystem calls
222-
const fastPathSection = generatedShellCode.substring(
223-
generatedShellCode.indexOf('If environment exists and has binaries, activate quickly'),
224-
generatedShellCode.indexOf('Continue with setup'),
225-
)
221+
// Should have background operations to avoid blocking
222+
expect(generatedShellCode).toContain('>/dev/null 2>&1 &')
223+
expect(generatedShellCode).toContain('disown 2>/dev/null || true')
226224

227-
// Should not have expensive operations like find in fast path
228-
expect(fastPathSection).not.toContain('find ')
229-
expect(fastPathSection).not.toContain('ls -A')
225+
// Should not have expensive operations in the main path
226+
expect(generatedShellCode).not.toContain('find ')
227+
expect(generatedShellCode).not.toContain('ls -A')
230228

231-
// Should minimize directory scans
232-
const touchOperations = (fastPathSection.match(/touch /g) || []).length
233-
expect(touchOperations).toBeLessThanOrEqual(2) // Cache file creation and timestamp sync
229+
// Should have instant activation logic
230+
expect(generatedShellCode).toContain('Instant activation - no external commands')
234231
})
235232

236233
it('should ensure cache variables are properly initialized', () => {

0 commit comments

Comments
 (0)