Revision control

1
import logging
2
import os
3
import subprocess
4
5
from .xcrun import XCRun
6
7
here = os.path.dirname(__file__)
8
logging.getLogger(__name__).addHandler(logging.NullHandler())
9
10
11
class XCodeBuild(object):
12
binary = 'xcodebuild'
13
destination = 'platform=iOS Simulator,name=iPhone X'
14
logger = logging.getLogger()
15
scheme = 'Fennec_Enterprise_XCUITests_Integration'
16
xcrun = XCRun()
17
18
def __init__(self, log):
19
self.log = log
20
21
def test(self, identifier):
22
self.xcrun.erase()
23
args = [
24
self.binary,
25
'test',
26
'-scheme', self.scheme,
27
'-destination', self.destination,
28
'-only-testing:{}'.format(identifier)]
29
self.logger.info('Running: {}'.format(' '.join(args)))
30
try:
31
out = subprocess.check_output(
32
args,
33
cwd=os.path.join(here, os.pardir),
34
stderr=subprocess.STDOUT)
35
except subprocess.CalledProcessError as e:
36
out = e.output
37
raise
38
finally:
39
with open(self.log, 'w') as f:
40
f.writelines(str(out))