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

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