1 | #!/usr/bin/env python2
|
2 | """import_smoosh.py.
|
3 |
|
4 | Choose between STDOUT and stdout-json assertions.
|
5 | """
|
6 | from __future__ import print_function
|
7 |
|
8 | import json
|
9 | import sys
|
10 |
|
11 |
|
12 | def main(argv):
|
13 | stdout_file = argv[1]
|
14 | with open(stdout_file) as f:
|
15 | expected = f.read()
|
16 |
|
17 | if expected.endswith('\n'): # not including empty
|
18 | print('## STDOUT:')
|
19 | print(expected, end='')
|
20 | print('## END')
|
21 | else:
|
22 | print('## stdout-json: %s' % json.dumps(expected))
|
23 |
|
24 |
|
25 | if __name__ == '__main__':
|
26 | try:
|
27 | main(sys.argv)
|
28 | except RuntimeError as e:
|
29 | print('FATAL: %s' % e, file=sys.stderr)
|
30 | sys.exit(1)
|