ci: verify chromedriver (#21993)
* initial pass * better * even better * ci * add chromedriver to build step * add chromedriver to other build step * persist chromedriver for tests * appveyor test * correct sys.platform names * chromedriver-path -> build-dir
This commit is contained in:
parent
1fb2b8e00e
commit
bdf65a75d0
3 changed files with 154 additions and 8 deletions
61
script/verify-chromedriver.py
Normal file
61
script/verify-chromedriver.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
|
||||
chromedriver_name = {
|
||||
'darwin': 'chromedriver',
|
||||
'win32': 'chromedriver.exe',
|
||||
'linux2': 'chromedriver'
|
||||
}
|
||||
|
||||
chromedriver_path = os.path.join(
|
||||
args.source_root, args.build_dir, chromedriver_name[sys.platform])
|
||||
proc = subprocess.Popen([chromedriver_path],
|
||||
stdout=subprocess.PIPE, universal_newlines=True)
|
||||
try:
|
||||
output = proc.stdout.readline()
|
||||
except KeyboardInterrupt:
|
||||
returncode = 0
|
||||
finally:
|
||||
proc.terminate()
|
||||
|
||||
returncode = 0
|
||||
match = re.search(
|
||||
'^Starting ChromeDriver [0-9]+.[0-9]+.[0-9]+.[0-9]+ .* on port [0-9]+$', output)
|
||||
|
||||
if match == None:
|
||||
returncode = 1
|
||||
|
||||
if returncode == 0:
|
||||
print('ok ChromeDriver is able to be initialized.')
|
||||
|
||||
return returncode
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser=argparse.ArgumentParser(description='Test ChromeDriver')
|
||||
parser.add_argument('--source-root',
|
||||
default=SOURCE_ROOT,
|
||||
required=False)
|
||||
parser.add_argument('--build-dir',
|
||||
default=None,
|
||||
required=True)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
Loading…
Add table
Add a link
Reference in a new issue