Python adapter test: interpreter probed twice can disagree on Windows (python3 vs python), failing CI at random

Aperta Adatta ai principianti
#304 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
github-actions, python, typescript
Ambito
ci-cd, testing-qa

Direzione di ricerca

Inizia da tests/repo/python-adapter.test.ts, in particolare dall’asserzione dell’interprete intorno alla riga 111; poi leggi src/repo/adapters/python.ts e la configurazione dell’interprete nel test intorno alla riga 70. Esegui il test dell’adattatore Python e verifica che confronti l’interprete registrato durante l’analisi oppure che, in alternativa, tolleri diversi launcher di Python 3 in base alla directory di lavoro. Il lavoro è completato quando l’errore su Windows non dipende più da due verifiche separate dell’interprete.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

tests/repo/python-adapter.test.ts ("selects the pytest files a change reaches and runs them with the interpreter it found") failed once on check (windows-latest, 24) for the docs-only PR #291 (run 44200296961, job 134452346206). The other three check jobs in that run passed:

AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+     executable: 'python3'
-     executable: 'python'
    at TestContext.<anonymous> (D:\a\core\core\tests\repo\python-adapter.test.ts:111:14)

Why it can disagree. The test and the adapter each probe for an interpreter, in different directories and at different times:

  • The test computes the expected interpreter once at module load: const interpreter = pythonInterpreter(process.cwd()); (L70).
  • The adapter calls pythonInterpreter() again, with the fixture's temp directory as cwd, when it builds the graph.
  • pythonInterpreter() (src/repo/adapters/python.ts L74) tries python3, then python, then py -3, each with a 10 s spawnSync timeout, and takes the first that prints 3.

On Windows runners, python3 is often the App Execution Alias stub or a slow first start. One probe can fail or time out on python3 and fall through to python, while the next probe succeeds with python3. The command the adapter writes is valid either way, but the assertion pins the test's own probe result.

This is not the known Rust temp-dir EBUSY/EPERM flake (#235); the failing test and the error are different. Recent Windows failures on other PRs were all the Rust one, so this looks rare.

Expected: the test asserts the interpreter the analysis recorded (or any working Python 3 launcher), not a second independent probe. Alternatively, pythonInterpreter() gives the same answer for the whole process, so one run cannot get two different interpreters.

Lingua principale
TypeScript
Stelle
0
Fork
4
Merge medio
18h 41m
PR unite (30g)
48

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di DiffCI/core

Tutte le issue di DiffCI/core

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.