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

Aberta Para iniciantes
#304 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
78/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
github-actions, python, typescript
Domínio
ci-cd, testing-qa

Direção de pesquisa

Comece por tests/repo/python-adapter.test.ts, especialmente pela asserção do interpretador por volta da linha 111; depois, leia src/repo/adapters/python.ts e a configuração do interpretador no teste por volta da linha 70. Execute o teste do adaptador Python e verifique se ele compara com o interpretador registrado durante a análise ou se, caso contrário, tolera diferentes inicializadores do Python 3 conforme o diretório de trabalho. O trabalho estará concluído quando a falha no Windows não depender mais de duas sondagens separadas do interpretador.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
TypeScript
Estrelas
0
Forks
4
Merge médio
18h 41min
PRs com merge (30d)
48

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de DiffCI/core

Todas as issues de DiffCI/core

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.