mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 17:57:02 +00:00
Turn BIMTester into a CLI app with ability to set arguments to Behave
This commit is contained in:
@@ -8,11 +8,20 @@ import pystache
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
import argparse
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
def run_tests():
|
def run_tests(args):
|
||||||
behave_main(['features', '--junit', '--junit-directory', 'junit/'])
|
behave_args = ['features', '--junit', '--junit-directory', 'junit/']
|
||||||
print('# All tests have finished. Generating HTML reports now.')
|
if args.advanced_arguments:
|
||||||
|
behave_args = args.advanced_arguments.split()
|
||||||
|
behave_main(behave_args)
|
||||||
|
print('# All tests are finished.')
|
||||||
|
if args.report:
|
||||||
|
generate_report()
|
||||||
|
|
||||||
|
def generate_report():
|
||||||
|
print('# Generating HTML reports now.')
|
||||||
if not os.path.exists('report'):
|
if not os.path.exists('report'):
|
||||||
os.mkdir('report')
|
os.mkdir('report')
|
||||||
if not os.path.exists('junit'):
|
if not os.path.exists('junit'):
|
||||||
@@ -84,29 +93,35 @@ class TestPurger:
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
print('# BIMTester')
|
parser = argparse.ArgumentParser(
|
||||||
print('''
|
description='Runs unit tests for BIM data')
|
||||||
BIMTester is free software developed under the IfcOpenShell and BlenderBIM
|
parser.add_argument(
|
||||||
projects. BIMTester allows advanced, fast, and human-readable BIM data analysis,
|
'-p',
|
||||||
and can be run automatically on open-source BIM servers. To learn more, visit:
|
'--purge',
|
||||||
|
action='store_true',
|
||||||
|
help='Purge tests of deleted elements')
|
||||||
|
parser.add_argument(
|
||||||
|
'-r',
|
||||||
|
'--report',
|
||||||
|
action='store_true',
|
||||||
|
help='Generate a HTML report')
|
||||||
|
parser.add_argument(
|
||||||
|
'-a',
|
||||||
|
'--advanced-arguments',
|
||||||
|
type=str,
|
||||||
|
help='Specify your own arguments to Python\'s Behave',
|
||||||
|
default='')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
- http://ifcopenshell.org
|
if not os.path.exists('features'):
|
||||||
- https://blenderbim.org
|
quit('''
|
||||||
|
BIMTester requires a features folder to exist within the current folder.
|
||||||
|
Visit https://blenderbim.org/ to learn more about how to use BIMTester.
|
||||||
|
''')
|
||||||
|
|
||||||
To run, a `features/` folder is required in the current folder.
|
if args.purge:
|
||||||
|
|
||||||
Please choose from the following options:
|
|
||||||
|
|
||||||
1. Run all tests
|
|
||||||
2. Purge non-existent element tests
|
|
||||||
''')
|
|
||||||
|
|
||||||
value = input('Please select an option: [1-2] ')
|
|
||||||
if value == '1':
|
|
||||||
run_tests()
|
|
||||||
elif value == '2':
|
|
||||||
TestPurger().purge()
|
TestPurger().purge()
|
||||||
else:
|
else:
|
||||||
quit()
|
run_tests(args)
|
||||||
|
|
||||||
print('# All tasks are complete :-)')
|
print('# All tasks are complete :-)')
|
||||||
input('Press <enter> to quit.')
|
|
||||||
|
|||||||
Reference in New Issue
Block a user