Files
jason.woltje 068d868a99 lead: commit rocko's untracked evidence (4471 files: queue-124 queue-129 queue-171 queue-178 queue-280 queue-31 queue-84 queue-85 queue-94)
Unclaimed files left in the canonical checkout. Inventory: canonical-cleanup-inventory.md (commit-as-evidence groups). detect-secrets scan clean on 2026-11-02: hits are sha256 pins, git object ids, test sentinels already in tracked tests and unit-file lines.
2026-11-02 15:05:15 -06:00

42 lines
3.2 KiB
Python

import pathlib,subprocess,sys,json,os,signal
root=pathlib.Path.cwd();out=pathlib.Path(sys.argv[1]);out.mkdir(parents=True,exist_ok=True)
assert root != pathlib.Path('/mnt/storage/src/mosaic-stack')
assert os.environ.get('DOCKER_HOST')=='unix:///nonexistent.sock'
stack='scripts/stack-copy.sh';bus='scripts/bus-service.sh';web='scripts/webui-service.sh'
suite=['packages/cli/tests/stack-copy.test.mjs'];wsuite=['packages/webui/tests/service.test.mjs'];psuite=['packages/webui/tests/pinned-copy.test.mjs']
muts=[
('ignore-pushed-ref',stack,'for ref in refs/heads/refactor refs/remotes/origin/refactor; do','for ref in refs/heads/refactor; do',suite),
('skip-npm',stack,'(cd "$tmp" && npm ci --no-audit --no-fund) >&2 || die',': || die',suite),
('skip-manifest-guard',stack,'[ -f "$tmp/package.json" ] && [ -f "$tmp/package-lock.json" ] || die',': || die',suite),
('missing-bus-schema',stack,'packages/bus/src packages/bus/schema.sql','packages/bus/src',suite),
('missing-adapters',stack,' adapters roles RELEASE',' roles RELEASE',suite),
('missing-queue',stack,' packages/queue/src\n','\n',suite),
('writable-copy-dirs',stack,'find "$tmp" -type d -exec chmod 0555 {} +','find "$tmp" -type d -exec chmod 0755 {} +',suite),
('writable-copy-files',stack,'find "$tmp" -type f -exec chmod a-w {} +',':',psuite),
('replace-existing',stack,'if [ -e "$target" ]; then echo "exists: $target"; return; fi',':',suite),
('accept-foreign-wrapper',stack,'[ "$(sed -n \'2p\' "$file")" = "$MARKER" ] || die',': || die',suite),
('accept-wrapper-symlink',stack,'[ -f "$file" ] && [ ! -L "$file" ] || die','[ -f "$file" ] || die',suite),
('lose-lease',stack,'"$MARKER" "$lease" "$root" > "$tmp"','"$MARKER" "# lease removed" "$root" > "$tmp"',suite),
('wrong-wrapper-tree',stack,'"$MARKER" "$lease" "$root" > "$tmp"','"$MARKER" "$lease" "/other" > "$tmp"',suite),
('ignore-effective-exec',stack,'[[ "$exec_start" == *"path=$root/scripts/mosaic ;"* ]]','[[ 1 == 1 ]]',suite),
('ignore-pm',bus,'[ "$PM" = 0 ] || pm_flags=" --pm"',':',suite),
('skip-install-guard',bus,' install_guard\n','',suite),
('ignore-dropin',bus,"if grep -Eq '^[[:space:]]*(ExecStart|WorkingDirectory)[[:space:]]*=' \"$file\"; then",'if false; then',suite),
('ignore-empty-metadata',bus,'grep -q \'^DropInPaths=\' <<< "$info" || die',': || die',suite),
('status-hides-pm',bus,'echo \'pm: on\'','echo \'pm: off\'',suite),
('console-skips-working-dir',web,'[ "$working" = "$copy" ] || die',': || die',wsuite),
]
results=[]
for name,file,old,new,tests in muts:
p=root/file;original=p.read_text();assert original.count(old)==1,(name,original.count(old))
try:
p.write_text(original.replace(old,new,1))
with (out/(name+'.txt')).open('w') as log:
child=subprocess.Popen(['node','--test',*tests],stdout=log,stderr=subprocess.STDOUT,start_new_session=True)
try:code=child.wait(timeout=60);status='killed' if code else 'survived'
except subprocess.TimeoutExpired:os.killpg(child.pid,signal.SIGKILL);child.wait();code=124;status='timeout'
row={'name':name,'exit':code,'status':status};results.append(row);print(json.dumps(row),flush=True)
(out/'summary.json').write_text(json.dumps(results,indent=2)+'\n')
finally:p.write_text(original)
sys.exit(any(r['status']!='killed' for r in results))