Skip to content

Commit 61862f1

Browse files
test: smoke installed CLI against real Git repository
1 parent dda3d3f commit 61862f1

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

global-template/docgen/test/git-inventory-regression.test.mjs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { projectPaths, writeJson } from '../lib/core.mjs';
1010

1111
const testDir = path.dirname(fileURLToPath(import.meta.url));
1212
const engineRoot = path.resolve(testDir, '..');
13+
const repositoryRoot = path.resolve(engineRoot, '..', '..');
1314

1415
function fixture() {
1516
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'docgen-git-inventory-'));
@@ -29,19 +30,47 @@ function fixture() {
2930
return root;
3031
}
3132

32-
test('git-aware inventory executes native git path enumeration', () => {
33+
function initializeGitFixture() {
3334
const root = fixture();
3435
const init = spawnSync('git', ['init'], { cwd: root, encoding: 'utf8' });
3536
assert.equal(init.status, 0, init.stderr || init.stdout);
3637
fs.writeFileSync(path.join(root, 'src', 'Tracked.java'), 'class Tracked {}\n');
3738
fs.writeFileSync(path.join(root, 'ignored.log'), 'ignore me\n');
3839
fs.writeFileSync(path.join(root, '.gitignore'), '*.log\n');
40+
return root;
41+
}
3942

43+
test('git-aware inventory executes native git path enumeration', () => {
44+
const root = initializeGitFixture();
4045
const inventory = buildInventory(root);
4146
assert(inventory.files.some((item) => item.path === 'src/Tracked.java'));
4247
assert(!inventory.files.some((item) => item.path === 'ignored.log'));
4348
});
4449

50+
test('installed launcher indexes a real Git repository', () => {
51+
const commandCodeHome = fs.mkdtempSync(path.join(os.tmpdir(), 'docgen-installed-home-'));
52+
const install = spawnSync(process.execPath, [
53+
path.join(repositoryRoot, 'install.mjs'),
54+
'--force',
55+
'--no-link-cli',
56+
'--no-hooks',
57+
'--commandcode-home',
58+
commandCodeHome
59+
], { cwd: repositoryRoot, encoding: 'utf8' });
60+
assert.equal(install.status, 0, `INSTALL STDERR:\n${install.stderr}\nINSTALL STDOUT:\n${install.stdout}`);
61+
62+
const root = initializeGitFixture();
63+
const launcher = path.join(commandCodeHome, 'docgen', 'bin', 'docgen-launcher.mjs');
64+
const run = spawnSync(process.execPath, [launcher, 'index'], {
65+
cwd: root,
66+
encoding: 'utf8',
67+
env: { ...process.env, DOCGEN_PROGRESS: '0' }
68+
});
69+
assert.equal(run.status, 0, `INDEX STDERR:\n${run.stderr}\nINDEX STDOUT:\n${run.stdout}`);
70+
assert.doesNotMatch(`${run.stdout}\n${run.stderr}`, /Bolean is not defined/);
71+
assert(fs.existsSync(path.join(root, '.docgen', 'index', 'semantic.db')));
72+
});
73+
4574
test('shipped JavaScript contains no misspelled Boolean global', () => {
4675
const stack = [engineRoot];
4776
const offenders = [];

0 commit comments

Comments
 (0)