aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2019-10-24 11:59:25 -0400
committerTom Rini <trini@konsulko.com>2019-10-30 17:48:47 -0400
commit8add4fa4177bf697ad892497fe65259dad642366 (patch)
tree3a3d158ad1582e54e578f6e5e4ef8c9aa49ac254 /test
parentd2b5240c9a0303e2d2ed3cd540d7e32b6f198664 (diff)
downloadu-boot-8add4fa4177bf697ad892497fe65259dad642366.zip
u-boot-8add4fa4177bf697ad892497fe65259dad642366.tar.gz
u-boot-8add4fa4177bf697ad892497fe65259dad642366.tar.bz2
test/py: Rework test.py to be a different kind of wrapper
Now that we have moved to being based on pytest for python3 we need to make our test.py wrapper more robust in terms of only calling python3 rather than possibly finding and using python2. To do this, change from execvp()'ing pytest to invoking the package itself via python. In the event that pytest is unavailable we still get a user-friendly error: pkg_resources.DistributionNotFound: The 'pytest' distribution was not found and is required by the application Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Stephen Warren <swarren@nvidia.com> Tested-by: Simon Glass <sjg@chromium.org> [on sandbox] Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'test')
-rwxr-xr-xtest/py/test.py20
1 files changed, 4 insertions, 16 deletions
diff --git a/test/py/test.py b/test/py/test.py
index 0ce1838..bee88d9 100755
--- a/test/py/test.py
+++ b/test/py/test.py
@@ -10,23 +10,11 @@
import os
import os.path
import sys
-
-# Get rid of argv[0]
-sys.argv.pop(0)
+from pkg_resources import load_entry_point
# argv; py.test test_directory_name user-supplied-arguments
-args = ['py.test', os.path.dirname(__file__) + '/tests']
+args = [os.path.dirname(__file__) + '/tests']
args.extend(sys.argv)
-try:
- os.execvp('py.test', args)
-except:
- # Log full details of any exception for detailed analysis
- import traceback
- traceback.print_exc()
- # Hint to the user that they likely simply haven't installed the required
- # dependencies.
- print('''
-exec(py.test) failed; perhaps you are missing some dependencies?
-See test/py/README.md for the list.''', file=sys.stderr)
- sys.exit(1)
+if __name__ == '__main__':
+ sys.exit(load_entry_point('pytest', 'console_scripts', 'pytest')(args))