mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-24 00:51:31 +01:00
Docs link check stops hiding sections after inline code, /learn prune checks every learning, /retro counts Godot test runners (#4677)
Four small fixes from outside reports: the docs link and prose checks no longer treat a line that starts with inline code as a code block, /learn prune reads every learning instead of the first 100, /retro counts a test runner in `tests/` and skips game-engine sidecar files, and five tests that cannot work as root now skip there. Why: each one was reproduced on main and gave a wrong answer (refused valid links, skipped stale learnings, a test total of 0, red tests as root). Nothing to do after merge. Co-authored-by: Davmunrey <108531295+Davmunrey@users.noreply.github.com> Co-authored-by: huongtran84 <4927097+huongtran84@users.noreply.github.com> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
12 files changed
+118
-13
No files matched your search
@@ -108,8 +108,12 @@ test('paid scope creation preserves non-Linux behavior without inherited qualifi
|
||||
}
|
||||
});
|
||||
|
||||
// Root passes the ptrace check that makes a nondumpable process's /proc/<pid>/cwd unreadable, so the uninspectable-process
|
||||
// paths these cases need cannot happen there.
|
||||
const NONDUMPABLE_DENIES = process.getuid?.() !== 0;
|
||||
|
||||
describe.skipIf(process.platform !== 'linux')('bootstrap attempt retention boundaries', () => {
|
||||
test('pre-existing same-uid nondumpable host process is not an attempt writer', async () => {
|
||||
test.skipIf(!NONDUMPABLE_DENIES)('pre-existing same-uid nondumpable host process is not an attempt writer', async () => {
|
||||
const child = await censusProcess('dumpable(0);');
|
||||
expect(fs.statSync(`/proc/${child.pid}`).uid).toBe(process.getuid!());
|
||||
expect(() => fs.readlinkSync(`/proc/${child.pid}/cwd`)).toThrow('EACCES');
|
||||
@@ -151,7 +155,7 @@ describe.skipIf(process.platform !== 'linux')('bootstrap attempt retention bound
|
||||
} finally { dir.mockRestore(); read.mockRestore(); }
|
||||
});
|
||||
|
||||
test.each(['new process', 'new denial', 'different lifetime'])('%s cannot inherit an unrelated process census exclusion', async scenario => {
|
||||
test.skipIf(!NONDUMPABLE_DENIES).each(['new process', 'new denial', 'different lifetime'])('%s cannot inherit an unrelated process census exclusion', async scenario => {
|
||||
const child = scenario === 'new process' ? undefined : await censusProcess(scenario === 'different lifetime'
|
||||
? 'dumpable(0);'
|
||||
: "process.stdin.once('data', () => { dumpable(0); console.log('changed'); });");
|
||||
@@ -265,7 +269,7 @@ describe.skipIf(process.platform !== 'linux')('bootstrap attempt retention bound
|
||||
} finally { stat.mockRestore(); }
|
||||
});
|
||||
|
||||
test('reusing a scope cannot baseline-exempt an unreadable process from its prior attempt', async () => {
|
||||
test.skipIf(!NONDUMPABLE_DENIES)('reusing a scope cannot baseline-exempt an unreadable process from its prior attempt', async () => {
|
||||
const { temporary, scope, root: outer } = fixture();
|
||||
const first = project(temporary);
|
||||
const retained = register(first, scope);
|
||||
|
||||
@@ -175,6 +175,33 @@ describe('link check', () => {
|
||||
} finally { fs.rmSync(path.join(repo, 'docs/a.md')); }
|
||||
});
|
||||
|
||||
// Value: protects=fence detection follows CommonMark, so a line that opens with an inline code span (as
|
||||
// docs/troubleshooting.md does) is text and only a bare run at least as long as the opening one closes a fence;
|
||||
// fails_when=the span opens a fence, every later heading and <a id> vanishes and valid links to them are refused, or
|
||||
// a shorter inner fence ends an example block early; why_new=no link test had a fence other than a plain pair; seam=none
|
||||
test('a line opening with an inline code span is text, and only a bare fence as long as the opening one closes a block', () => {
|
||||
put('docs/f.md', [
|
||||
'````gstack-ship-receipt```` is a section of its own.',
|
||||
'',
|
||||
'## After the span',
|
||||
'',
|
||||
'````markdown',
|
||||
'```mermaid',
|
||||
'# Inside the example',
|
||||
'``` ',
|
||||
'```` trailing text',
|
||||
'````',
|
||||
'',
|
||||
'[span](#after-the-span) [example](#inside-the-example) [after](#after-the-example)',
|
||||
'',
|
||||
'## After the example',
|
||||
'',
|
||||
].join('\n'));
|
||||
try {
|
||||
expect(brokenLinks(repo, ['docs/f.md']).map(b => b.target)).toEqual(['#inside-the-example']);
|
||||
} finally { fs.rmSync(path.join(repo, 'docs/f.md')); }
|
||||
});
|
||||
|
||||
test('added lines cover quoted and spaced names and untracked files, an undecodable anchor is broken, and an unknown base throws', () => {
|
||||
const names = ['docs/café.md', 'docs/with space.md'];
|
||||
try {
|
||||
|
||||
@@ -203,6 +203,18 @@ describe('B6: rank by matched tokens and disclose truncation', () => {
|
||||
expect(runIn(rankCwd, ['--limit', '3']).stdout).not.toContain('more matched');
|
||||
});
|
||||
|
||||
// Value: protects=/learn prune reads every learning, so an old entry that decay pushed past any limit still gets checked;
|
||||
// fails_when=--all is refused or still cuts the list at a limit; why_new=prune read --limit 100 and silently skipped the
|
||||
// rest of a larger store (#4215); seam=none
|
||||
test('--all prints every entry, past the default limit', () => {
|
||||
const unique = Number(/^UNIQUE: (\d+)/m.exec(runIn(rankCwd, ['--stats']).stdout)![1]);
|
||||
expect(unique).toBeGreaterThan(10);
|
||||
const r = runIn(rankCwd, ['--all']);
|
||||
expect(r.status).toBe(0);
|
||||
expect(keys(r.stdout)).toHaveLength(unique);
|
||||
expect(r.stdout).toContain(`LEARNINGS: ${unique} loaded`);
|
||||
});
|
||||
|
||||
test('a stored internal field cannot hijack the no-query ranking', () => {
|
||||
const ranked = keys(runIn(rankCwd, ['--limit', '3']).stdout);
|
||||
expect(ranked).toHaveLength(3);
|
||||
|
||||
@@ -411,6 +411,27 @@ describe('gstack-retro-metrics test census beyond JS/TS', () => {
|
||||
}
|
||||
});
|
||||
|
||||
// Value: protects=a repo whose only test is a runner in tests/ with no test-style name (a Godot tests/run.gd) still
|
||||
// counts it, and engine sidecars (Godot .uid/.import, Unity .meta) never count as tests; fails_when=TEST_FILES_TOTAL
|
||||
// reads 0 there or the .uid sidecar counts as a changed test file; why_new=every census fixture names its tests by
|
||||
// convention; seam=none
|
||||
test('a repo with no conventionally named tests counts code files in its test dir', () => {
|
||||
const dir = fixtureRepo('gstack-rm-godot-', {
|
||||
'games/brick.gd': 'extends Node\n',
|
||||
'tests/run.gd': 'extends SceneTree\n',
|
||||
'tests/run.gd.uid': 'uid://abc\n',
|
||||
'tests/README.md': '# how to run\n',
|
||||
});
|
||||
try {
|
||||
const out = runMetrics(['--base', 'main', '--since', '2026-03-09T00:00:00'], dir);
|
||||
expect(out).toMatch(/^TEST_FILES_TOTAL: 1$/m);
|
||||
expect(out).toMatch(/^TEST_FILES_CHANGED: 1$/m);
|
||||
expect(out).toMatch(/^TEST_INSERTIONS: 1$/m);
|
||||
} finally {
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('Swift/XCTest naming counts; generated output and prose specs do not', () => {
|
||||
const dir = fixtureRepo('gstack-rm-swift-', {
|
||||
'App/Store.swift': 'struct Store {}\n',
|
||||
|
||||
@@ -130,6 +130,14 @@ describe('lintProse: each rule, positive and negative', () => {
|
||||
expect(lintProse(text, 'x.md').map(f => [f.rule, f.line])).toEqual([['dropped-article', 5], ['unclosed-block', 9]]);
|
||||
});
|
||||
|
||||
// Value: protects=a line that opens with an inline code span is prose, so the lines after it are still read;
|
||||
// fails_when=the span opens a fence, later prose is masked as code and the next bare fence reads as an unclosed block
|
||||
// that stops the scan; why_new=every fence case above opens with a bare or info-string fence line; seam=none
|
||||
test('a line opening with an inline code span is prose, and the lines after it are read', () => {
|
||||
const text = ['````gstack-ship-receipt```` is a section of its own.', 'This vibrant line is read.', '````', '```json', '{"vibrant": true}', '```', '````'].join('\n');
|
||||
expect(lintProse(text, 'x.md').map(f => [f.rule, f.line])).toEqual([['vocabulary', 2]]);
|
||||
});
|
||||
|
||||
test('findings are sorted by line and the render ends in the trailer', () => {
|
||||
const text = renderProseLint({ findings: lintProse('Showcasing a vibrant release.\n\nParser rejects it.', 'f.md'), scanned: ['f.md'], empty: [] });
|
||||
expect(text.split('\n').filter(Boolean)).toEqual([
|
||||
|
||||
Reference in new issue
Block a user