test: py: Use global pytestmark for hush tests
PATCH v2 1/2 test: py: Use global pytestmark for hush tests
All tests in test_hush_if_test depends on hush parser to be present. This patch simplify test dependencies by using global pytestmark.
---
Changes in v2:
- Fix line-wrapping in comming message
test/py/tests/test_hush_if_test.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
test/py/tests/test_hush_if_test.py +2 -4
@@ -8,6 +8,8 @@ import os import os.path import pytest +pytestmark = pytest.mark.buildconfigspec('hush_parser') + # The list of "if test" conditions to test. subtests = ( # Base if functionality.
@@ -109,27 +111,23 @@ def exec_hush_if(u_boot_console, expr, result): response = u_boot_console.run_command(cmd) assert response.strip() == str(result).lower() - at pytest.mark.buildconfigspec('hush_parser') def test_hush_if_test_setup(u_boot_console): """Set up environment variables used during the "if" tests.""" u_boot_console.run_command('setenv ut_var_nonexistent') u_boot_console.run_command('setenv ut_var_exists 1') - at pytest.mark.buildconfigspec('hush_parser') @pytest.mark.parametrize('expr,result', subtests) def test_hush_if_test(u_boot_console, expr, result): """Test a single "if test" condition.""" exec_hush_if(u_boot_console, expr, result) - at pytest.mark.buildconfigspec('hush_parser') def test_hush_if_test_teardown(u_boot_console): """Clean up environment variables used during the "if" tests.""" u_boot_console.run_command('setenv ut_var_exists') - at pytest.mark.buildconfigspec('hush_parser') # We might test this on real filesystems via UMS, DFU, 'save', etc. # Of those, only UMS currently allows file removal though. @pytest.mark.boardspec('sandbox')
Signature · 1 line
1.9.1
PATCH v2 2/2 test: py: hush: Add echo dependency
Some tests depends on echo command to be present.
---
Changes in v2:
- New patch in this series
- Tested on sandbox
test/py/tests/test_hush_if_test.py | 2 ++ 1 file changed, 2 insertions(+)
test/py/tests/test_hush_if_test.py +2 -0
@@ -117,6 +117,7 @@ def test_hush_if_test_setup(u_boot_console): u_boot_console.run_command('setenv ut_var_nonexistent') u_boot_console.run_command('setenv ut_var_exists 1') + at pytest.mark.buildconfigspec('cmd_echo') @pytest.mark.parametrize('expr,result', subtests) def test_hush_if_test(u_boot_console, expr, result): """Test a single "if test" condition."""
@@ -130,6 +131,7 @@ def test_hush_if_test_teardown(u_boot_console): # We might test this on real filesystems via UMS, DFU, 'save', etc. # Of those, only UMS currently allows file removal though. + at pytest.mark.buildconfigspec('cmd_echo') @pytest.mark.boardspec('sandbox') def test_hush_if_test_host_file_exists(u_boot_console): """Test the "if test -e" shell command."""
Signature · 1 line
1.9.1
PATCH v2 2/2 test: py: hush: Add echo dependency
test/py/tests/test_hush_if_test.py def test_hush_if_test_setup(u_boot_console): · line 123
Quoted 8 lines · Michal Simek
Some tests depends on echo command to be present.
test/py/tests/test_hush_if_test.py +1
-0+ at pytest.mark.buildconfigspec('cmd_echo') @pytest.mark.parametrize('expr,result', subtests) def test_hush_if_test(u_boot_console, expr, result): """Test a single "if test" condition."""
This change is technically correct I admit.
However, there's not much point allowing test_hush_if_test_setup() and test_hush_if_test_teardown() to run if test_hush_if_test() doesn't run, so I'd be inclined to make this a file-level mark rather than a function-/test-level mark, just like the other mark for the dependency on CONFIG_HUSH_PARSER.
Still, either way is OK I guess.
PATCH v2 2/2 test: py: hush: Add echo dependency
Quoted 13 lines · Stephen Warren
test/py/tests/test_hush_if_test.py def test_hush_if_test_setup(u_boot_console): · line 123
Quoted 9 lines · Michal Simek
Some tests depends on echo command to be present.
test/py/tests/test_hush_if_test.py +1
-0+ at pytest.mark.buildconfigspec('cmd_echo') @pytest.mark.parametrize('expr,result', subtests) def test_hush_if_test(u_boot_console, expr, result): """Test a single "if test" condition."""This change is technically correct I admit.
Quoted 7 lines
However, there's not much point allowing
test_hush_if_test_setup()andtest_hush_if_test_teardown()to run iftest_hush_if_test()doesn't run, so I'd be inclined to make this a file-level mark rather than a function-/test-level mark, just like the other mark for the dependency onCONFIG_HUSH_PARSER.Still, either way is OK I guess.
I choose this way because in future someone can add more tests for hush which won't use echo. And still that two tests which runs are doing something what can failed that's why not run them.
Anyway not a problem to mark the whole file too if syntax enables it.
Thanks,
Michal
PATCH v2 2/2 test: py: hush: Add echo dependency
In reply to Michal SimekQuoted 4 lines · Michal Simek
Some tests depends on echo command to be present.
Reported-by Stephen Warren <[email protected]>Signed-off-by Michal Simek <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170605/bb8468c8/attachment.sig>
PATCH v2 1/2 test: py: Use global pytestmark for hush tests
In reply to Michal SimekQuoted 3 lines · Michal Simek
All tests in
test_hush_if_testdepends on hush parser to be present. This patch simplify test dependencies by using global pytestmark.
PATCH v2 1/2 test: py: Use global pytestmark for hush tests
In reply to Michal SimekQuoted 7 lines · Michal Simek
All tests in
test_hush_if_testdepends on hush parser to be present. This patch simplify test dependencies by using global pytestmark.Reported-by Stephen Warren <[email protected]>Signed-off-by Michal Simek <[email protected]>Acked-by Stephen Warren <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170605/85d44fed/attachment.sig>