Skip to content

Commit d53c8d8

Browse files
committed
test(plugins): say that Windows has no chmod 000 for the project state file case (#3348)
Windows has no POSIX mode bits: `chmod 000` only toggles the read-only attribute, so the PROJECT.md the case writes still reads, the listing names its size and hash, and the assertion that expected `unreadable: PROJECT.md (EACCES)` fails — the red windows-latest compat leg of run 45278160728 (job 138055341383, step "Plugin tests (project)"). The skip guard covered only root: on Windows `process.getuid` is undefined, so `undefined === 0` is false and the case ran. `plugins/project/test/platform.js` is the same `posix` / `win32` pair the four older plugin suites got in #3300, and the chmod case now names both limits in its skip: a root process on POSIX, and every Windows process. The other three cases in the file are platform-neutral and keep running everywhere. Docs-not-needed: the change is test-only; docs/subsystems/project.md describes the reader's behaviour, which this change does not touch.
1 parent f10b503 commit d53c8d8

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎plugins/project/test/platform.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// The few assertions of this suite that are POSIX-shaped, in one place so every Windows case names
2+
// what the platform can and cannot express instead of dropping the assertion (#3298, the way
3+
// core/test/platform.js does it for the core suite).
4+
//
5+
// Windows has no POSIX mode bits: `chmod` only toggles the read-only attribute, so a state file
6+
// cannot be made unreadable for its owner, and a case that writes `chmod 000` and expects `EACCES`
7+
// reads the file there instead and asserts the wrong answer (#3348). Only that one case is skipped
8+
// on Windows; the rest of the suite is platform-neutral and runs everywhere.
9+
export const posix = process.platform !== 'win32'
10+
export const win32 = !posix

‎plugins/project/test/project-state-unreadable.test.js‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { test } from 'node:test'
1717
import { createRuntime, provideFlyBot } from 'ds-bot'
1818
import { apply as applyProject } from '../index.js'
1919
import { fakeContext } from '../../../core/test/fake-ctx.js'
20+
import { win32 } from './platform.js'
2021

2122
const TEAM = {
2223
version: 1, mainBotIds: ['a'],
@@ -88,9 +89,15 @@ test('#2461: a Project State file that cannot be read keeps its name and reason
8889
})
8990

9091
// A root process reads a chmod 000 file, so this case is declared skipped rather than run there —
91-
// the shape `core/test/diagnostics.test.js` already uses for its own root-only cases.
92+
// the shape `core/test/diagnostics.test.js` already uses for its own root-only cases. Windows has no
93+
// POSIX mode bits at all: `chmod 000` only toggles the read-only attribute, so the file still reads
94+
// and the row is listed instead of answered as unreadable. Both limits are named in the skip, and the
95+
// other three cases in this file run on every platform (`./platform.js`, as `#3300` did it for the
96+
// other plugin suites).
9297
test('#2461: a state file the process may not read answers its code, not an empty folder', {
93-
skip: process.getuid?.() === 0 ? 'root reads a chmod 000 file' : undefined,
98+
skip: win32
99+
? 'Windows has no POSIX mode bits: chmod 000 does not deny a read'
100+
: process.getuid?.() === 0 ? 'root reads a chmod 000 file' : undefined,
94101
}, async (t) => {
95102
const dir = emptyRepository()
96103
writeFileSync(join(dir, 'PROJECT.md'), '# Project\n')

0 commit comments

Comments
 (0)