mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-09-29 12:07:05 -07:00
Real gap caught by live CI (Builds - MacOS's 6000.0.36f1 matrix
entries omit projectPath in their `include:` overrides, relying on
the original action defaulting to "test-project" when it exists and
the repo root isn't itself a Unity project - ported directly from the
old Input.projectPath getter). Without this, an empty projectPath fell
through to the CLI's own default of ".", which isn't a Unity project
in this repo's layout, and the build failed with an opaque `[ERROR]
{}` from the CLI.
resolve-project-path.ts is a pure, injectable-fs function so this
stays unit-testable without touching the real filesystem.
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { resolveProjectPath } from './resolve-project-path';
|
|
|
|
function fsOf(existingPaths: string[]) {
|
|
return {
|
|
joinPath: (...segments: string[]) => segments.join('/'),
|
|
existsSync: (candidate: string) => existingPaths.includes(candidate),
|
|
};
|
|
}
|
|
|
|
describe('resolveProjectPath', () => {
|
|
it('returns the explicit input unchanged when given', () => {
|
|
const result = resolveProjectPath({
|
|
input: 'my-project',
|
|
...fsOf(['test-project/ProjectSettings/ProjectVersion.txt']),
|
|
});
|
|
|
|
expect(result).toBe('my-project');
|
|
});
|
|
|
|
it('strips a trailing slash from an explicit input', () => {
|
|
const result = resolveProjectPath({ input: 'my-project/', ...fsOf([]) });
|
|
|
|
expect(result).toBe('my-project');
|
|
});
|
|
|
|
it('defaults to "test-project" when it looks like a Unity project and the repo root does not', () => {
|
|
const result = resolveProjectPath({
|
|
input: '',
|
|
...fsOf(['test-project/ProjectSettings/ProjectVersion.txt']),
|
|
});
|
|
|
|
expect(result).toBe('test-project');
|
|
});
|
|
|
|
it('does not default to "test-project" when the repo root is itself a Unity project', () => {
|
|
const result = resolveProjectPath({
|
|
input: '',
|
|
...fsOf([
|
|
'test-project/ProjectSettings/ProjectVersion.txt',
|
|
'ProjectSettings/ProjectVersion.txt',
|
|
]),
|
|
});
|
|
|
|
expect(result).toBe('');
|
|
});
|
|
|
|
it('returns empty (letting the cli default to ".") when neither location looks like a Unity project', () => {
|
|
const result = resolveProjectPath({ input: '', ...fsOf([]) });
|
|
|
|
expect(result).toBe('');
|
|
});
|
|
});
|