Changes to get cli testing in CI and other test fixes

This commit is contained in:
Mark Roszko 2023-05-04 10:37:44 -04:00 committed by Marek Roszko
parent 995388fb71
commit 112aa66be5
7 changed files with 41 additions and 30 deletions

View File

@ -26,6 +26,7 @@
-DCMAKE_BUILD_TYPE=QABUILD
-DKICAD_STDLIB_LIGHT_DEBUG=ON
-DKICAD_BUILD_I18N=ON
-DKICAD_TEST_XML_OUTPUT=ON
../../
- ninja 2>&1 | tee compilation_log.txt
- cd ../../
@ -37,6 +38,8 @@
when: always
paths:
- build/linux/3d-viewer/
- build/linux/eeschema/_eeschema.kiface
- build/linux/kicad/kicad-cli
- build/linux/pcbnew/pcbnew.py
- build/linux/pcbnew/_pcbnew.kiface
- build/linux/pcbnew/_pcbnew.so
@ -138,10 +141,12 @@ fedora_report_metrics_public:
extends:
- .unit_test
- .only_code
before_script:
- if [ "$TEST" == "cli" ]; then python3 -m pip install -r qa/tests/requirements.txt; fi
parallel:
matrix:
# The name of the test without the qa_ prefix
- TEST: [python, common, gerbview, pcbnew, eeschema, kimath, sexpr, kicad2step, spice]
- TEST: [python, common, gerbview, pcbnew, eeschema, kimath, sexpr, kicad2step, spice, cli]
fedora_qa_kicad:
extends: .fedora_qa

View File

@ -31,7 +31,9 @@
# are processed in the junit report (https://gitlab.com/gitlab-org/gitlab/issues/23835)
# so we can't use a glob and have to list out each hierarchy separately.
artifacts:
when: always
paths:
- build/linux/qa/**/*.log
reports:
junit:
- build/linux/qa/*/*.xml
- build/linux/qa/*/*/*.xml
- build/linux/qa/**/*.xml

View File

@ -62,7 +62,7 @@ if( KICAD_TEST_XML_OUTPUT )
# Due to Boost issue in 1.62, have to use the --logger parameter, rather than
# separate --log_format, --log_sink, etc parameter
# https://svn.boost.org/trac10/ticket/12507
set(BOOST_TEST_PARAMS --logger=XML,all,${TEST_NAME}.boost-results.xml --report_level=no --result_code=no)
set(BOOST_TEST_PARAMS --logger=JUNIT,all,${TEST_NAME}.boost-results.xml --report_level=no --result_code=no)
endif()
# Add the test to the CTest registry

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -32,20 +32,20 @@ endif()
if( KICAD_TEST_XML_OUTPUT )
# To do this, you will need xmlrunner
set( PYTEST_ARGS_QAPYTHON --xml=${CMAKE_CURRENT_BINARY_DIR}/qapython.xunit-results )
set( PYTEST_ARGS_QACLI --junitxml=${CMAKE_CURRENT_BINARY_DIR}/qacli.junit-results )
set( PYTEST_ARGS_QAPYTHON --xml=${CMAKE_CURRENT_BINARY_DIR}/qapython.xunit-results.xml )
set( PYTEST_ARGS_QACLI --junitxml=${CMAKE_CURRENT_BINARY_DIR}/qacli.junit-results.xml )
endif()
if( MSVC )
# avoid formatting this otherwise you will introduce whitespace into the PATH string
set( QA_PATH_REPLACEMENT
"PATH=${CMAKE_BINARY_DIR}/kicad/;\
${CMAKE_BINARY_DIR}/pcbnew/;\
${CMAKE_BINARY_DIR}/eeschema/;\
$ENV{PATH};" )
endif()
if (UNIX)
string(REPLACE ";" ":" QA_PATH_REPLACEMENT "${QA_PATH_REPLACEMENT}")
endif()
if( NOT (MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug") )
# qa_python will never work under MSVC + Debug because we only have the Release mode python.exe
@ -58,7 +58,7 @@ add_test( NAME qa_python
set_tests_properties( qa_python
PROPERTIES
ENVIRONMENT "${QA_PATH_REPLACEMENT}PYTHONPATH=${CMAKE_BINARY_DIR}/pcbnew;${PYTHON_QA_PATH}"
ENVIRONMENT "${QA_PATH_REPLACEMENT};PYTHONPATH=${CMAKE_BINARY_DIR}/pcbnew;${PYTHON_QA_PATH}"
)
endif()

View File

@ -28,8 +28,8 @@ from pathlib import Path
import pytest
@pytest.mark.parametrize("test_file,output_dir,compare_fn,cli_args",
[("cli\\basic_test\\basic_test.kicad_sch", "basic_test", "cli\\basic_test\\basic_test.png", []),
("cli\\basic_test\\basic_test.kicad_sch", "basic_test_nobg_bnw_nods", "cli\\basic_test\\basic_test_nobg_bnw_nods.png", ["--no-background-color", "--exclude-drawing-sheet", "--black-and-white"])
[("cli/basic_test/basic_test.kicad_sch", "basic_test", "cli/basic_test/basic_test.png", []),
("cli/basic_test/basic_test.kicad_sch", "basic_test_nobg_bnw_nods", "cli/basic_test/basic_test_nobg_bnw_nods.png", ["--no-background-color", "--exclude-drawing-sheet", "--black-and-white"])
])
def test_sch_export_svg( kitest,
image_diff,
@ -39,7 +39,7 @@ def test_sch_export_svg( kitest,
cli_args: list):
input_file = kitest.get_data_file_path( test_file )
output_path = kitest.get_output_path( "cli\\{}\\".format( output_dir ) )
output_path = kitest.get_output_path( "cli/{}/".format( output_dir ) )
command = ["kicad-cli", "sch", "export", "svg"]
command.extend( cli_args )
@ -51,6 +51,7 @@ def test_sch_export_svg( kitest,
assert exitcode == 0
assert stderr == ''
assert stdout is not None
stdout_regex = re.match("^Plotted to '(.+)'", stdout)
assert stdout_regex
@ -70,22 +71,23 @@ def test_sch_export_svg( kitest,
assert image_diff( png_converted_from_svg_path, compare_file_path, throw_exception=False )
@pytest.mark.parametrize("test_file,output_fn,line_skip_count,cli_args",
[("cli\\basic_test\\basic_test.kicad_sch", "basic_test.netlist.kicadsexpr", 5, []),
("cli\\basic_test\\basic_test.kicad_sch", "basic_test.netlist.kicadsexpr", 5, ["--format=kicadsexpr"]),
("cli\\basic_test\\basic_test.kicad_sch", "basic_test.netlist.kicadxml", 6, ["--format=kicadxml"]),
("cli\\basic_test\\basic_test.kicad_sch", "basic_test.netlist.cadstar", 3, ["--format=cadstar"]),
("cli\\basic_test\\basic_test.kicad_sch", "basic_test.netlist.orcadpcb2", 1, ["--format=orcadpcb2"])
@pytest.mark.parametrize("test_file,output_fn,line_skip_count,skip_compare,cli_args",
[("cli/basic_test/basic_test.kicad_sch", "basic_test.netlist.kicadsexpr", 5, True, []),
("cli/basic_test/basic_test.kicad_sch", "basic_test.netlist.kicadsexpr", 5, True,["--format=kicadsexpr"]),
("cli/basic_test/basic_test.kicad_sch", "basic_test.netlist.kicadxml", 6, True,["--format=kicadxml"]),
("cli/basic_test/basic_test.kicad_sch", "basic_test.netlist.cadstar", 3, False, ["--format=cadstar"]),
("cli/basic_test/basic_test.kicad_sch", "basic_test.netlist.orcadpcb2", 1, False, ["--format=orcadpcb2"])
])
def test_sch_export_netlist( kitest,
test_file: str,
output_fn: str,
line_skip_count: int,
skip_compare: bool,
cli_args: list):
input_file = kitest.get_data_file_path( test_file )
compare_filepath = kitest.get_data_file_path( "cli\\basic_test\\{}".format( output_fn ) )
compare_filepath = kitest.get_data_file_path( "cli/basic_test/{}".format( output_fn ) )
output_filepath = kitest.get_output_path( "cli\\" ).joinpath( output_fn )
output_filepath = kitest.get_output_path( "cli/" ).joinpath( output_fn )
command = ["kicad-cli", "sch", "export", "netlist"]
command.extend( cli_args )
@ -98,15 +100,17 @@ def test_sch_export_netlist( kitest,
assert exitcode == 0
assert stderr == ''
assert utils.textdiff_files( compare_filepath, str( output_filepath ), line_skip_count )
# some of our netlist formats are not cross platform so skip for now
if not skip_compare:
assert utils.textdiff_files( compare_filepath, str( output_filepath ), line_skip_count )
kitest.add_attachment( str( output_filepath ) )
@pytest.mark.parametrize("test_file,output_fn,cli_args",
[("cli\\basic_test\\basic_test.kicad_sch", "basic_test.pdf", []),
("cli\\basic_test\\basic_test.kicad_sch", "basic_test.bnw.nods.nobg.pdf", ["--black-and-white","--exclude-drawing-sheet","--no-background-color"]),
("cli\\basic_test\\basic_test.kicad_sch", "basic_test.pone.pdf", ["--plot-one"])
[("cli/basic_test/basic_test.kicad_sch", "basic_test.pdf", []),
("cli/basic_test/basic_test.kicad_sch", "basic_test.bnw.nods.nobg.pdf", ["--black-and-white","--exclude-drawing-sheet","--no-background-color"]),
("cli/basic_test/basic_test.kicad_sch", "basic_test.pone.pdf", ["--plot-one"])
])
def test_sch_export_pdf( kitest,
test_file: str,
@ -114,7 +118,7 @@ def test_sch_export_pdf( kitest,
cli_args: list):
input_file = kitest.get_data_file_path( test_file )
output_filepath = kitest.get_output_path( "cli\\" ).joinpath( output_fn )
output_filepath = kitest.get_output_path( "cli/" ).joinpath( output_fn )
command = ["kicad-cli", "sch", "export", "pdf"]
command.extend( cli_args )
@ -131,7 +135,7 @@ def test_sch_export_pdf( kitest,
@pytest.mark.parametrize("test_file,output_fn,line_skip_count,cli_args",
[("cli\\basic_test\\basic_test.kicad_sch", "basic_test.pythonbom", 6, [])
[("cli/basic_test/basic_test.kicad_sch", "basic_test.pythonbom", 6, [])
])
def test_sch_export_pythonbom( kitest,
test_file: str,
@ -139,9 +143,9 @@ def test_sch_export_pythonbom( kitest,
line_skip_count: int,
cli_args: list):
input_file = kitest.get_data_file_path( test_file )
compare_filepath = kitest.get_data_file_path( "cli\\basic_test\\{}".format( output_fn ) )
compare_filepath = kitest.get_data_file_path( "cli/basic_test/{}".format( output_fn ) )
output_filepath = kitest.get_output_path( "cli\\" ).joinpath( output_fn )
output_filepath = kitest.get_output_path( "cli/" ).joinpath( output_fn )
command = ["kicad-cli", "sch", "export", "python-bom"]
command.extend( cli_args )
@ -154,6 +158,6 @@ def test_sch_export_pythonbom( kitest,
assert exitcode == 0
assert stderr == ''
assert utils.textdiff_files( compare_filepath, str( output_filepath ), line_skip_count )
# pythonbom is not currently crossplatform (platform specific paths) to enable diffs
kitest.add_attachment( str( output_filepath ) )