]> git.sur5r.net Git - u-boot/blob - test/py/test.py
test/py: Make print statements python 3.x safe
[u-boot] / test / py / test.py
1 #!/usr/bin/env python2
2 # SPDX-License-Identifier: GPL-2.0
3
4 # Copyright (c) 2015 Stephen Warren
5 # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
6
7 # Wrapper script to invoke pytest with the directory name that contains the
8 # U-Boot tests.
9
10 from __future__ import print_function
11
12 import os
13 import os.path
14 import sys
15
16 # Get rid of argv[0]
17 sys.argv.pop(0)
18
19 # argv; py.test test_directory_name user-supplied-arguments
20 args = ['py.test', os.path.dirname(__file__) + '/tests']
21 args.extend(sys.argv)
22
23 try:
24     os.execvp('py.test', args)
25 except:
26     # Log full details of any exception for detailed analysis
27     import traceback
28     traceback.print_exc()
29     # Hint to the user that they likely simply haven't installed the required
30     # dependencies.
31     print('''
32 exec(py.test) failed; perhaps you are missing some dependencies?
33 See test/py/README.md for the list.''', file=sys.stderr)
34     sys.exit(1)