From 3367cf2fdd0df44a7bc099fcabd7e2002e09776a Mon Sep 17 00:00:00 2001 From: sickn33 Date: Sun, 29 Mar 2026 09:27:19 +0200 Subject: [PATCH] test(repo): Prevent Python test bytecode drift Set PYTHONDONTWRITEBYTECODE for the shared Python runner and the root test-suite launcher so local test runs do not create __pycache__ artifacts inside skills. This keeps npm run test deterministic and avoids false negatives in the editorial bundle inventory checks. --- tools/scripts/run-python.js | 6 ++++++ tools/scripts/tests/run-test-suite.js | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/scripts/run-python.js b/tools/scripts/run-python.js index 16535de4..6a3d6223 100644 --- a/tools/scripts/run-python.js +++ b/tools/scripts/run-python.js @@ -5,6 +5,10 @@ const { spawn, spawnSync } = require('node:child_process'); const args = process.argv.slice(2); +const PYTHON_ENV = { + ...process.env, + PYTHONDONTWRITEBYTECODE: process.env.PYTHONDONTWRITEBYTECODE || '1', +}; if (args.length === 0) { console.error('Usage: node tools/scripts/run-python.js [args...]'); @@ -47,6 +51,7 @@ function canRun(candidate) { command, [...baseArgs, '-c', 'import sys; raise SystemExit(0 if sys.version_info[0] == 3 else 1)'], { + env: PYTHON_ENV, stdio: 'ignore', shell: false, }, @@ -67,6 +72,7 @@ if (!selected) { const [command, ...baseArgs] = selected; const child = spawn(command, [...baseArgs, ...args], { + env: PYTHON_ENV, stdio: 'inherit', shell: false, }); diff --git a/tools/scripts/tests/run-test-suite.js b/tools/scripts/tests/run-test-suite.js index 44668c75..c85d4982 100644 --- a/tools/scripts/tests/run-test-suite.js +++ b/tools/scripts/tests/run-test-suite.js @@ -58,7 +58,13 @@ function isNetworkTestsEnabled() { } function runNodeCommand(args) { - const result = spawnSync(process.execPath, args, { stdio: "inherit" }); + const result = spawnSync(process.execPath, args, { + env: { + ...process.env, + PYTHONDONTWRITEBYTECODE: process.env.PYTHONDONTWRITEBYTECODE || "1", + }, + stdio: "inherit", + }); if (result.error) { throw result.error;