From f61a06ae2df756e1518256923f464f9bbb61b2bd Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 3 Mar 2022 11:46:29 +0100 Subject: [PATCH 1/3] De-parallelize and increase verbosity of integration tests --- test/conftest.py | 4 ++-- test/pytest.ini | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index 37d3b8d0c95..8f164848385 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -124,7 +124,7 @@ def run_command(pytestconfig, data_dir, downloads_dir, working_dir): } (Path(data_dir) / "packages").mkdir(exist_ok=True) - def _run(cmd: list, custom_working_dir=None, custom_env=None): + def _run(cmd: list, custom_working_dir=None, custom_env=None, hide=False): if cmd is None: cmd = [] quoted_cmd = [f'"{t}"' for t in cmd] @@ -144,7 +144,7 @@ def _run(cmd: list, custom_working_dir=None, custom_env=None): # It escapes spaces in the path using "\ " but it doesn't always work, # wrapping the path in quotation marks is the safest approach with run_context.prefix(f'{cd_command} "{custom_working_dir}"'): - return run_context.run(cli_full_line, echo=False, hide=True, warn=True, env=custom_env, encoding="utf-8") + return run_context.run(cli_full_line, echo=True, hide=hide, warn=True, env=custom_env, encoding="utf-8") return _run diff --git a/test/pytest.ini b/test/pytest.ini index ea573791a7b..7ce113c41e5 100644 --- a/test/pytest.ini +++ b/test/pytest.ini @@ -14,4 +14,4 @@ markers = # -n=auto sets the numbers of parallel processes to use # --dist=loadfile distributes the tests in the parallel processes dividing them per file # See https://pypi.org/project/pytest-xdist/#parallelization for more info on parallelization -addopts = -x -s --verbose --tb=long -n=auto --dist=loadfile +addopts = -x -s --verbose --tb=long From f97e56ac59c3745d4a239ed198585b8f43ed23f2 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 30 May 2022 18:08:54 +0200 Subject: [PATCH 2/3] Hide output of some test Otherwise Windows runners may raise this exception: E UnicodeEncodeError: 'charmap' codec can't encode characters in position 890-897: character maps to --- test/test_board.py | 4 ++-- test/test_completion.py | 6 +++--- test/test_lib.py | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/test_board.py b/test/test_board.py index d696101b594..15e70789fdb 100644 --- a/test/test_board.py +++ b/test/test_board.py @@ -516,7 +516,7 @@ def test_board_details_list_programmers_without_flag(run_command): run_command(["core", "update-index"]) # Download samd core pinned to 1.8.6 run_command(["core", "install", "arduino:samd@1.8.6"]) - result = run_command(["board", "details", "-b", "arduino:samd:nano_33_iot"]) + result = run_command(["board", "details", "-b", "arduino:samd:nano_33_iot"], hide=True) assert result.ok lines = [l.strip().split() for l in result.stdout.splitlines()] assert ["Programmers:", "Id", "Name"] in lines @@ -529,7 +529,7 @@ def test_board_details_list_programmers_flag(run_command): run_command(["core", "update-index"]) # Download samd core pinned to 1.8.6 run_command(["core", "install", "arduino:samd@1.8.6"]) - result = run_command(["board", "details", "-b", "arduino:samd:nano_33_iot", "--list-programmers"]) + result = run_command(["board", "details", "-b", "arduino:samd:nano_33_iot", "--list-programmers"], hide=True) assert result.ok lines = [l.strip() for l in result.stdout.splitlines()] diff --git a/test/test_completion.py b/test/test_completion.py index 2b4410fda6a..7c0118f8bd7 100644 --- a/test/test_completion.py +++ b/test/test_completion.py @@ -135,11 +135,11 @@ def test_config_completion(run_command): # here we test if the completions coming from the libs are working def test_lib_completion(run_command): assert run_command(["lib", "update-index"]) - result = run_command(["__complete", "lib", "install", ""]) + result = run_command(["__complete", "lib", "install", ""], hide=True) assert "WiFi101" in result.stdout - result = run_command(["__complete", "lib", "download", ""]) + result = run_command(["__complete", "lib", "download", ""], hide=True) assert "WiFi101" in result.stdout - result = run_command(["__complete", "lib", "uninstall", ""]) + result = run_command(["__complete", "lib", "uninstall", ""], hide=True) assert "WiFi101" not in result.stdout # not yet installed assert run_command(["lib", "install", "WiFi101"]) diff --git a/test/test_lib.py b/test/test_lib.py index 4c444c0c147..22dac17fec4 100644 --- a/test/test_lib.py +++ b/test/test_lib.py @@ -58,7 +58,7 @@ def test_list(run_command): assert result.ok assert "" == result.stderr assert "No libraries installed." in result.stdout.strip() - result = run_command(["lib", "list", "--format", "json"]) + result = run_command(["lib", "list", "--format", "json"], hide=True) assert result.ok assert "" == result.stderr assert 0 == len(json.loads(result.stdout)) @@ -83,7 +83,7 @@ def test_list(run_command): assert "An efficient and elegant JSON library..." == toks[4] # Look at the JSON output - result = run_command(["lib", "list", "--format", "json"]) + result = run_command(["lib", "list", "--format", "json"], hide=True) assert result.ok assert "" == result.stderr data = json.loads(result.stdout) @@ -159,7 +159,7 @@ def test_list_with_fqbn(run_command): assert "ArduinoJson" == toks[0] # Look at the JSON output - result = run_command(["lib", "list", "-b", "arduino:avr:uno", "--format", "json"]) + result = run_command(["lib", "list", "-b", "arduino:avr:uno", "--format", "json"], hide=True) assert result.ok assert "" == result.stderr data = json.loads(result.stdout) @@ -180,7 +180,7 @@ def test_list_provides_includes_fallback(run_command): assert run_command(["lib", "install", "ArduinoJson@6.17.2"]) # List all libraries, even the ones installed with the above core - result = run_command(["lib", "list", "--all", "--fqbn", "arduino:avr:uno", "--format", "json"]) + result = run_command(["lib", "list", "--all", "--fqbn", "arduino:avr:uno", "--format", "json"], hide=True) assert result.ok assert "" == result.stderr @@ -545,7 +545,7 @@ def test_lib_list_with_updatable_flag(run_command): assert "An efficient and elegant JSON library..." == line[4] # Look at the JSON output - res = run_command(["lib", "list", "--updatable", "--format", "json"]) + res = run_command(["lib", "list", "--updatable", "--format", "json"], hide=True) assert res.ok assert "" == res.stderr data = json.loads(res.stdout) From 4c6c42a94c6ed1a4fc673b012100280df955c5e2 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 31 May 2022 15:37:41 +0200 Subject: [PATCH 3/3] Update test/pytest.ini Co-authored-by: Umberto Baldi <34278123+umbynos@users.noreply.github.com> --- test/pytest.ini | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/pytest.ini b/test/pytest.ini index 7ce113c41e5..efa3923446b 100644 --- a/test/pytest.ini +++ b/test/pytest.ini @@ -11,7 +11,5 @@ markers = # -s to disable per-test capture # --verbose is what is says it is # --tb=long sets the length of the traceback in case of failures -# -n=auto sets the numbers of parallel processes to use -# --dist=loadfile distributes the tests in the parallel processes dividing them per file # See https://pypi.org/project/pytest-xdist/#parallelization for more info on parallelization addopts = -x -s --verbose --tb=long