forked from shaka-project/shaka-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·97 lines (81 loc) · 2.91 KB
/
test.py
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
90
91
92
93
94
95
96
97
#!/usr/bin/python
#
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Runs unit and integrations tests on the library."""
import platform
import subprocess
import sys
import build
import gendeps
import shakaBuildHelpers
def run_tests(args):
"""Runs all the karma tests."""
# Update node modules if needed.
if not shakaBuildHelpers.update_node_modules():
return 1
# Generate dependencies and compile library.
# This is required for the tests.
if gendeps.gen_deps([]) != 0:
return 1
build_args = []
if '--force' in args:
build_args.append('--force')
args.remove('--force')
if '--no-build' in args:
args.remove('--no-build')
else:
if build.main(build_args) != 0:
return 1
karma_command_name = 'karma'
if shakaBuildHelpers.is_windows():
# Windows karma program has a different name
karma_command_name = 'karma.cmd'
karma_path = shakaBuildHelpers.get_node_binary_path(karma_command_name)
cmd = [karma_path, 'start']
# Get the browsers supported on the local system.
browsers = _get_browsers()
if not browsers:
print >> sys.stderr, 'Unrecognized system "%s"' % platform.uname()[0]
return 1
print 'Starting tests...'
if not args:
# Run tests in all available browsers.
print 'Running with platform default:', '--browsers', browsers
cmd_line = cmd + ['--browsers', browsers]
shakaBuildHelpers.print_cmd_line(cmd_line)
return subprocess.call(cmd_line)
else:
# Run with command-line arguments from the user.
if '--browsers' not in args:
print 'No --browsers specified.'
print 'In this mode, browsers must be manually connected to karma.'
cmd_line = cmd + args
shakaBuildHelpers.print_cmd_line(cmd_line)
return subprocess.call(cmd_line)
def _get_browsers():
"""Uses the platform name to configure which browsers will be tested."""
browsers = None
if shakaBuildHelpers.is_linux():
# For MP4 support on Linux Firefox, install gstreamer1.0-libav.
# Opera on Linux only supports MP4 for Ubuntu 15.04+, so it is not in the
# default list of browsers for Linux at this time.
browsers = 'Chrome,Firefox'
elif shakaBuildHelpers.is_darwin():
browsers = 'Chrome,Firefox,Safari'
elif shakaBuildHelpers.is_windows() or shakaBuildHelpers.is_cygwin():
browsers = 'Chrome,Firefox,IE'
return browsers
if __name__ == '__main__':
shakaBuildHelpers.run_main(run_tests)