File: test_print_quit.py

package info (click to toggle)
eureka 2.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,912 kB
  • sloc: cpp: 84,842; python: 495; sh: 91; makefile: 21; ansic: 3
file content (61 lines) | stat: -rw-r--r-- 1,882 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import argparse
import re
import subprocess

# test script expects the executable as argument
parser = argparse.ArgumentParser()
parser.add_argument('--executable',
                    help='full path to executable')
parser.add_argument('--version',
                    help='Eureka version string')
args = parser.parse_args()

IMMEDIATE_RUN_TIMEOUT = 3

def test_help_command():
    result = subprocess.check_output([args.executable, '--help'],
                                      timeout=IMMEDIATE_RUN_TIMEOUT).decode('utf-8')
    assert 'Eureka is free software, under the terms of the GNU General' in result
    assert 'USAGE: ' in result
    assert '--version' in result

    lines = result.split('\n')

    parms = set()

    # Check that all the <name> columns are aligned
    saved_pos = None
    for line in lines:
        pos = line.find('<')
        match = re.search('--[a-z_]+', line)
        if match:
            parm = match.group()
            parms.add(parm)
        if pos != -1:
            if saved_pos is not None:
                assert pos == saved_pos
            else:
                saved_pos = pos

    assert parms == {'--home', '--install', '--log', '--config', '--help', '--version', '--debug',
        '--quiet', '--file', '--merge', '--iwad', '--port', '--warp',
    }

    # Check that '<' marked arguments (like -warp) have an extra newline after
    in_warp = False
    for line in lines:
        if '-warp' in line:
            in_warp = True
            continue
        if in_warp:
            assert not line.strip() # check that we have an empty line here
            in_warp = False

def test_version_command():
    result = str(subprocess.check_output([args.executable, '--version'],
                                         timeout=IMMEDIATE_RUN_TIMEOUT))
    assert args.version in result


test_help_command()
test_version_command()