From 8e3e793353484c6cbde4c365ac148f4e422b6ae8 Mon Sep 17 00:00:00 2001 From: Obijuan Date: Sun, 17 Mar 2024 21:21:14 +0100 Subject: [PATCH] apio test refactoring --- apio/commands/test.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/apio/commands/test.py b/apio/commands/test.py index c7af0aef..c7876604 100644 --- a/apio/commands/test.py +++ b/apio/commands/test.py @@ -1,16 +1,25 @@ # -*- coding: utf-8 -*- # -- This file is part of the Apio project -# -- (C) 2016-2019 FPGAwars -# -- Author Jesús Arroyo +# -- (C) 2016-2024 FPGAwars +# -- Authors +# -- * Jesús Arroyo (2016-2019) +# -- * Juan Gonzalez (obijuan) (2019-2024) # -- Licence GPLv2 -"""TODO""" +"""Main implementation of APIO TEST command""" import click from apio.managers.scons import SCons from apio import util +# ------------------ +# -- CONSTANTS +# ------------------ +CMD = "test" # -- Comand name +PROJECT_DIR = "project_dir" # -- Option +TESTBENCH = "testbench" # -- Option -@click.command("test", context_settings=util.context_settings()) + +@click.command(CMD, context_settings=util.context_settings()) @click.pass_context @click.option( "-p", @@ -21,13 +30,21 @@ ) @click.option( "-t", - "--testbench", + f"--{TESTBENCH}", type=str, metavar="testbench", help="Test only this testbench file.", ) -def cli(ctx, project_dir, testbench): +def cli(ctx, **kwargs): + # def cli(ctx, project_dir, testbench): """Launch the verilog testbench testing.""" - exit_code = SCons(project_dir).test({"testbench": testbench}) + # -- Extract the arguments + project_dir = kwargs[PROJECT_DIR] + testbench = kwargs[TESTBENCH] + + # -- Create the scons object + scons = SCons(project_dir) + + exit_code = scons.test({"testbench": testbench}) ctx.exit(exit_code)