Completed
Push — master ( bed8ce...e75872 )
by Chris
01:20
created

check_tests()   A

Complexity

Conditions 4

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
c 1
b 0
f 0
dl 0
loc 8
rs 9.2
1
"""A python runner for nodejs test files."""
2
3
import os
4
import subprocess
5
import sys
6
7
8
def check_tests():
9
    """Run all tests."""
10
    js_files = [f for f in os.listdir('.') if f.endswith('Spec.js')]
11
    results = dict()
12
    for spec in js_files:
13
        results[spec] = subprocess.call(['jasmine', spec])
14
    all_passed = sum(results.values()) == 0
15
    return all_passed
16
17
18
if __name__ == '__main__':
19
    # Return a standard exit code for CI pipelines to use.
20
    code = 1 if not check_tests() else 0
21
    print('=' * 80)
22
    print('Test results: {}'.format('passed' if code == 0 else 'failed!'))
23
    print('=' * 80)
24
    sys.exit(code)
25