28 lines
1.4 KiB
TypeScript
28 lines
1.4 KiB
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
import { mkdirSync, mkdtempSync } from 'node:fs';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { toolPath, wellKnownToolDirs } from '../cli/lib/tools';
|
|
|
|
describe('tool folders outside PATH', () => {
|
|
test('finds the Android SDK Android Studio installs, after the own PATH', () => {
|
|
const home = mkdtempSync(join(tmpdir(), 'sb-home-'));
|
|
mkdirSync(join(home, 'Library/Android/sdk/platform-tools'), { recursive: true });
|
|
mkdirSync(join(home, 'Library/Android/sdk/emulator'), { recursive: true });
|
|
const env = { HOME: home, PATH: '/usr/bin:/bin' };
|
|
expect(wellKnownToolDirs(env, 'darwin')).toContain(join(home, 'Library/Android/sdk/platform-tools'));
|
|
const p = toolPath(env, 'darwin').split(':');
|
|
expect(p.slice(0, 2)).toEqual(['/usr/bin', '/bin']);
|
|
expect(p).toContain(join(home, 'Library/Android/sdk/emulator'));
|
|
});
|
|
|
|
test('ANDROID_HOME wins, missing folders are skipped, app folders come first', () => {
|
|
const sdk = mkdtempSync(join(tmpdir(), 'sb-sdk-'));
|
|
mkdirSync(join(sdk, 'platform-tools'));
|
|
const env = { HOME: '/nonexistent', ANDROID_HOME: sdk, PATH: '/usr/bin', STOREBOUND_TOOL_PATH: '/app/tools' };
|
|
const p = toolPath(env, 'linux').split(':');
|
|
expect(p[0]).toBe('/app/tools');
|
|
expect(p).toContain(join(sdk, 'platform-tools'));
|
|
expect(p).not.toContain(join(sdk, 'emulator'));
|
|
});
|
|
});
|