2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-12 00:06:36 +00:00

fix(tests): print traceback from errors

This commit is contained in:
Gavin D'souza 2020-07-13 19:01:51 +05:30
parent a73d38851b
commit 6dc784fe4d
4 changed files with 28 additions and 8 deletions

View File

@ -18,42 +18,42 @@ matrix:
- name: "Python 2.7 Basic Setup"
python: 2.7
env: TEST=bench
script: python -m unittest -v bench.tests.test_init
script: python -m unittest -v bench.tests.basic
- name: "Python 3.6 Basic Setup"
python: 3.6
env: TEST=bench
script: python -m unittest -v bench.tests.test_init
script: python -m unittest -v bench.tests.basic
- name: "Python 3.7 Basic Setup"
python: 3.7
env: TEST=bench
script: python -m unittest -v bench.tests.test_init
script: python -m unittest -v bench.tests.basic
- name: "Python 3.8 Production Setup"
python: 3.8
env: TEST=bench
script: python -m unittest -v bench.tests.test_setup_production
script: python -m unittest -v bench.tests.production_setup
- name: "Python 2.7 Production Setup"
python: 2.7
env: TEST=bench
script: python -m unittest -v bench.tests.test_setup_production
script: python -m unittest -v bench.tests.production_setup
- name: "Python 3.6 Production Setup"
python: 3.6
env: TEST=bench
script: python -m unittest -v bench.tests.test_setup_production
script: python -m unittest -v bench.tests.production_setup
- name: "Python 3.7 Production Setup"
python: 3.7
env: TEST=bench
script: python -m unittest -v bench.tests.test_setup_production
script: python -m unittest -v bench.tests.production_setup
- name: "Python 3.8 Production Setup"
python: 3.8
env: TEST=bench
script: python -m unittest -v bench.tests.test_setup_production
script: python -m unittest -v bench.tests.production_setup
- name: "Python 3.6 Easy Install"
python: 3.6

View File

@ -102,3 +102,9 @@ class TestBenchBase(unittest.TestCase):
if os.environ.get("CI"):
return not subprocess.call(["sudo", "test", "-f", path])
return os.path.isfile(path)
def get_traceback(self):
exc_type, exc_value, exc_tb = sys.exc_info()
trace_list = traceback.format_exception(exc_type, exc_value, exc_tb)
body = "".join(str(t) for t in trace_list)
return body

View File

@ -34,6 +34,13 @@ class TestBenchInit(TestBenchBase):
self.assert_config(bench_name)
def basic(self):
try:
self.test_init()
except Exception:
print(self.get_traceback())
def test_multiple_benches(self):
for bench_name in ("test-bench-1", "test-bench-2"):
self.init_bench(bench_name)

View File

@ -33,6 +33,13 @@ class TestSetupProduction(TestBenchBase):
bench.utils.exec_cmd("sudo bench disable-production", cwd=bench_path)
def production_setup(self):
try:
self.test_setup_production()
except Exception:
print(self.get_traceback())
def assert_nginx_config(self, bench_name):
conf_src = os.path.join(os.path.abspath(self.benches_path), bench_name, 'config', 'nginx.conf')
conf_dest = "/etc/nginx/conf.d/{bench_name}.conf".format(bench_name=bench_name)