File: run_windows_tests.py

package info (click to toggle)
ibm-3270 4.3ga10-5
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 115,140 kB
  • sloc: xml: 610,537; ansic: 148,024; python: 8,664; sh: 6,360; makefile: 1,186; exp: 281; perl: 223; pascal: 129; tcl: 105; cpp: 21
file content (89 lines) | stat: -rwxr-xr-x 2,532 bytes parent folder | download
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python3
# Run windows tests.

import os
import os.path
import sys
import unittest
import glob

# Check the platform.
if not sys.platform.startswith('win'):
    if sys.platform == 'cygwin':
        print('On Cygwin, this needs to run using a native Windows copy of Python.', file=sys.stderr)
    else:
        print('Only works on native Windows, Cygwin and MSYS2.', file=sys.stderr)
    exit(1)

# Parse command-line options.
verbose = False
verbose_flag = ''
build = True
dirs = ['lib', 's3270', 'b3270', 'c3270', 'wc3270', 'pr3287']
args = sys.argv[1:]
while len(args) > 0 and args[0][0] == '-':
    if args[0] == '-v':
        verbose = True
        verbose_flag = '-v'
    elif args[0] == '-nobuild':
        build = False
    else:
        print(f"Unknown option '{args[0]}'")
        exit(1)
    args = args[1:]
if len(args) > 0:
    dirs = args

# Run Makefile/gcc-based tests.
def run_gcc_tests():
    # Build the code.
    if build and os.system('make windows') != 0:
        exit(1)

    # Run the library tests.
    if 'lib' in dirs:
        dirs.remove('lib')
        if os.system('make windows-lib-test') != 0:
            exit(1)

    # Set the path.
    if os.path.exists('obj\\win64'):
        obj = 'obj\\win64'
    elif os.path.exists('obj\\win32'):
        obj = 'obj\\win32'
    else:
        print("Missing object directory.", file=sys.stderr)
        exit(1)
    os.environ['PATH'] = ';'.join([os.getcwd() + '\\' + obj + '\\' + dir for dir in dirs] + [os.environ['PATH']])

    # Run the tests.
    cmd = sys.executable + ' -m unittest ' + verbose_flag + ' ' + ' '.join([' '.join(glob.glob(dir + '\\Test\\test*.py')) for dir in dirs])
    os.system(cmd)

# Run Visual Studio tests.
def run_vs_tests():
    
    # Build the code.
    os.chdir('VisualStudio')
    if build and os.system('msbuild /p:Configuration=Debug /p:Platform=x64') != 0:
        exit(1)
    os.chdir('..')

    # Run the library tests.
    if 'lib' in dirs:
        dirs.remove('lib')
        for test in ['base64', 'bind_opts', 'json', 'utf8']:
            if verbose:
                print(test + '_test')
            if os.system(f'VisualStudio\\x64\\Debug\\{test}_test.exe') !=0:
                exit(1)

    # Run the emulator tests.
    cmd = 'python3 -m unittest ' + verbose_flag + ' ' + ' '.join([' '.join(glob.glob(dir + '\\Test\\test*.py')) for dir in dirs])
    os.system(cmd)

# Guess whether we are supposed to build/run with VS or gcc.
if 'DevEnvDir' in os.environ:
    run_vs_tests()
else:
    run_gcc_tests()