2016-05-23 19:50:08 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
from unittest import *
|
|
|
|
from console.include.common_functions_60 import *
|
|
|
|
from console.include.common_classes_60 import *
|
2016-05-27 18:26:47 +02:00
|
|
|
from sauceclient import SauceClient
|
2016-07-12 09:35:02 +02:00
|
|
|
from os import environ, getenv
|
2016-05-27 18:26:47 +02:00
|
|
|
import subprocess, time, sys
|
2016-05-23 19:50:08 +02:00
|
|
|
|
2016-08-22 11:17:02 +02:00
|
|
|
def get_test_file(test_list):
|
|
|
|
#return [test[0].split(' ')[0].split('.')[0].split('<')[1] for test in test_list]
|
|
|
|
return [test[0].test_name for test in test_list]
|
2016-05-23 19:50:08 +02:00
|
|
|
|
2016-08-22 11:17:02 +02:00
|
|
|
#Run Enterprise tests
|
2016-08-19 13:17:47 +02:00
|
|
|
is_enterprise = '1' == getenv('ENTERPRISE', False)
|
|
|
|
|
2016-08-22 11:17:02 +02:00
|
|
|
a = TestLoader()
|
2016-08-19 13:17:47 +02:00
|
|
|
|
2016-08-22 11:17:02 +02:00
|
|
|
tests = a.discover(start_dir='console',pattern='*.py')
|
2016-08-19 13:17:47 +02:00
|
|
|
|
2016-08-22 11:17:02 +02:00
|
|
|
c = ArticaTestResult()
|
|
|
|
tests.run(c)
|
|
|
|
|
|
|
|
#Update Saouce Labs jobs
|
|
|
|
sauce_client = SauceClient(environ["SAUCE_USERNAME"], environ["SAUCE_ACCESS_KEY"])
|
|
|
|
for test,error_msg in c.failures+c.errors:
|
|
|
|
try:
|
2016-09-05 18:13:20 +02:00
|
|
|
sauce_client.jobs.update_job(test.sauce_labs_job_id, passed=False,tags=[environ["TRAVIS_BRANCH"],test.id()],build_num=environ["TRAVIS_JOB_NUMBER"],name=str(environ["TRAVIS_COMMIT"])+"_"+str(test.id().split('.')[1]+': '+test.id().split('.')[2]))
|
2016-08-22 11:17:02 +02:00
|
|
|
except:
|
|
|
|
print "Could not annotate Sauce Labs job #%s" % str(test)
|
|
|
|
next
|
|
|
|
|
|
|
|
for test,error_msg in c.success+c.skipped:
|
|
|
|
try:
|
2016-09-05 18:13:20 +02:00
|
|
|
sauce_client.jobs.update_job(test.sauce_labs_job_id, passed=True,tags=[environ["TRAVIS_BRANCH"],test.id()],build_num=environ["TRAVIS_JOB_NUMBER"],name=str(environ["TRAVIS_COMMIT"])+"_"+str(test.id().split('.')[1]+': '+test.id().split('.')[2])
|
2016-08-22 11:17:02 +02:00
|
|
|
except:
|
|
|
|
print "Could not annotate Sauce Labs job #%s" % str(test)
|
|
|
|
next
|
|
|
|
|
2016-08-22 11:09:32 +02:00
|
|
|
|
2016-08-19 13:17:47 +02:00
|
|
|
|
2016-08-22 11:17:02 +02:00
|
|
|
print "Tests failed: %s" % c.failures
|
|
|
|
print "Tests succeeded: %s" % c.success
|
|
|
|
print "Tests skipped: %s" % c.skipped
|
|
|
|
print "Tests with errors: %s" % c.errors
|
2016-08-19 13:17:47 +02:00
|
|
|
|
2016-08-22 11:17:02 +02:00
|
|
|
if (len(c.failures)+len(c.errors)) != 0:
|
2016-08-19 13:17:47 +02:00
|
|
|
sys.exit(1)
|
2016-08-22 11:17:02 +02:00
|
|
|
|
2016-05-27 21:34:36 +02:00
|
|
|
else:
|
|
|
|
sys.exit(0)
|