OILS / test / smoosh_import.py View on Github | oilshell.org

30 lines, 19 significant
1#!/usr/bin/env python2
2"""import_smoosh.py.
3
4Choose between STDOUT and stdout-json assertions.
5"""
6from __future__ import print_function
7
8import json
9import sys
10
11
12def 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
25if __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)