Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

KeyError in test scheduler when using TestBench.scan_tests_from_file()

Aperta Adatta ai principianti
#1,240 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@robindust-ce ci sta già lavorando.

Dal 18/10/2026.

  • #1241 di @robindust-ce — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
testing

Direzione di ricerca

Inizia in runner.py, in TestScheduler._create_test_suite_sets, e segui come i nomi dei file restituiti da TestBench.scan_tests_from_file() vengono associati alla mappa delle dipendenze. Esegui due volte l’esempio allegato con python run.py per riprodurre l’errore. Il lavoro è completo quando la seconda esecuzione non genera più un KeyError per il percorso relativo e la prioritizzazione dei test continua a funzionare.

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

Descrizione

Since test prioritization (08b2a6d2), the second run of a test bench whose tests are scanned via scan_tests_from_file() crashes with KeyError in TestScheduler._create_test_suite_sets (runner.py) when the file name is not spelled exactly like the project source file name (absolute, native str). A relative path, a pathlib.Path or a posix-style path on Windows all trigger it. The first run passes because there is no test history yet.

Reproduce: attached example, run python run.py twice.

Expected: scan_tests_from_file() normalizes the file name (or resolves it to the project source file), or the scheduler tolerates unknown file names.

run.py

from pathlib import Path
from vunit import VUnit

ROOT = Path(__file__).parent

vu = VUnit.from_argv()
vu.add_vhdl_builtins()
lib = vu.add_library("lib")
lib.add_source_files(ROOT / "*.vhd")  # added with absolute paths

tb = lib.test_bench("tb_top")
# Same file, but spelled as a relative path -> not a key of the dependency map
tb.scan_tests_from_file("tests.vhd")

vu.main()

tb_top.vhd

library vunit_lib;
context vunit_lib.vunit_context;

-- Test bench without tests of its own: the test cases live in tests.vhd
-- (legacy structure supported via TestBench.scan_tests_from_file()).
entity tb_top is
  generic (runner_cfg : string);
end entity;

architecture tb of tb_top is
begin
  i_tests : entity work.tests
    generic map (nested_runner_cfg => runner_cfg);
end architecture;

test.vhd

library vunit_lib;
context vunit_lib.vunit_context;

entity tests is
  generic (nested_runner_cfg : string);
end entity;

architecture a of tests is
begin
  main : process
  begin
    test_runner_setup(runner, nested_runner_cfg);
    while test_suite loop
      if run("test_a") then
        check_true(true);
      elsif run("test_b") then
        check_true(true);
      end if;
    end loop;
    test_runner_cleanup(runner);
  end process;
end architecture;
Lingua principale
VHDL
Stelle
850
Fork
305
Merge medio
2g 10h
PR unite (30g)
7

Preparare l'ambiente

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 VUnit/vunit

Tutte le issue di VUnit/vunit

Issue simili

Altre issue su Testing & QA

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.