mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-02 13:04:49 +00:00
bimtester: run, merge run and run wich copy in temp
This commit is contained in:
@@ -33,9 +33,20 @@ def run_tests(args):
|
|||||||
|
|
||||||
report_file = os.path.join("report", "report.json")
|
report_file = os.path.join("report", "report.json")
|
||||||
|
|
||||||
if not get_features(args):
|
if "copyintemprun" in args and args["copyintemprun"] is True:
|
||||||
print("No features could be found to check.")
|
print("copyintemprun")
|
||||||
return False
|
is_copyintemprun = True
|
||||||
|
args, copy_base_path = copy_intmp_tests(args)
|
||||||
|
features_path = os.path.join(copy_base_path, "features")
|
||||||
|
report_file = os.path.join(copy_base_path, report_file)
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("No copyintemprun")
|
||||||
|
is_copyintemprun = False
|
||||||
|
if not get_features(args):
|
||||||
|
print("No features could be found to check.")
|
||||||
|
return False
|
||||||
|
features_path = get_resource_path("features")
|
||||||
|
|
||||||
# get behave args
|
# get behave args
|
||||||
behave_args = get_behave_args(args, features_path, report_file)
|
behave_args = get_behave_args(args, features_path, report_file)
|
||||||
@@ -47,7 +58,10 @@ def run_tests(args):
|
|||||||
print("Error, not able to run behave because of empty behave args.")
|
print("Error, not able to run behave because of empty behave args.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
if is_copyintemprun is True:
|
||||||
|
return report_file
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def get_behave_args(args, features_path, report_file):
|
def get_behave_args(args, features_path, report_file):
|
||||||
@@ -164,23 +178,9 @@ reset_runtime()
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def run_copyintmp_tests(args={}):
|
def copy_intmp_tests(args={}):
|
||||||
|
|
||||||
"""
|
print("# Copy features and steps to temp.")
|
||||||
run bimtester unit test in a temporary directory
|
|
||||||
features, steps and environment.py are copied to a temp directory
|
|
||||||
|
|
||||||
Keys of parameter args
|
|
||||||
----------------------
|
|
||||||
features: optional (ATM mandatory)
|
|
||||||
the path the features directory with feature files is in
|
|
||||||
ifcfile: optional (ATM mandatory)
|
|
||||||
the ifc file
|
|
||||||
advanced_arguments: optional
|
|
||||||
they will be directly passed to the behave call
|
|
||||||
"""
|
|
||||||
|
|
||||||
print("# Run run_copyintmp_tests.")
|
|
||||||
|
|
||||||
from behave import __version__ as behave_version
|
from behave import __version__ as behave_version
|
||||||
# https://github.com/behave/behave/issues/871
|
# https://github.com/behave/behave/issues/871
|
||||||
@@ -266,7 +266,6 @@ def run_copyintmp_tests(args={}):
|
|||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
os.mkdir(copy_base_path)
|
os.mkdir(copy_base_path)
|
||||||
report_file = os.path.join(copy_base_path, "report", "report.json")
|
|
||||||
copy_features_path = os.path.join(copy_base_path, "features")
|
copy_features_path = os.path.join(copy_base_path, "features")
|
||||||
|
|
||||||
# copy features path from bimtester source code
|
# copy features path from bimtester source code
|
||||||
@@ -307,17 +306,7 @@ def run_copyintmp_tests(args={}):
|
|||||||
cp_feature_file
|
cp_feature_file
|
||||||
)
|
)
|
||||||
|
|
||||||
# get behave args
|
return args, copy_base_path
|
||||||
behave_args = get_behave_args(args, copy_features_path, report_file)
|
|
||||||
|
|
||||||
# run tests
|
|
||||||
if behave_args != []:
|
|
||||||
run_behave(behave_args)
|
|
||||||
else:
|
|
||||||
print("Error, not able to run behave because of empty behave args.")
|
|
||||||
return False
|
|
||||||
|
|
||||||
return copy_base_path
|
|
||||||
|
|
||||||
|
|
||||||
def run_all(args):
|
def run_all(args):
|
||||||
@@ -325,21 +314,21 @@ def run_all(args):
|
|||||||
print("# Run all.")
|
print("# Run all.")
|
||||||
|
|
||||||
# run bimtester
|
# run bimtester
|
||||||
runpath = run_copyintmp_tests(args)
|
report_file = run_tests(args)
|
||||||
print(runpath)
|
print(report_file)
|
||||||
|
|
||||||
# check if it worked out well
|
# check if it worked out well
|
||||||
if runpath is False:
|
if report_file is False:
|
||||||
print("BIMTester behave tests returned False.")
|
print("BIMTester behave tests returned False.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not os.path.isdir(runpath):
|
if not os.path.isfile(report_file):
|
||||||
print("runpath does not exist. This should not happen. Debug")
|
print("Report directory does not exist. This should not happen. Debug")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# create html report and open in webbrowser
|
# create html report and open in webbrowser
|
||||||
from .reports import generate_report
|
from .reports import generate_report
|
||||||
generate_report(runpath)
|
generate_report(report_file=report_file)
|
||||||
# get the feature files
|
# get the feature files
|
||||||
feature_files = os.listdir(
|
feature_files = os.listdir(
|
||||||
os.path.join(args["featuresdir"], "features")
|
os.path.join(args["featuresdir"], "features")
|
||||||
@@ -347,8 +336,7 @@ def run_all(args):
|
|||||||
# print(feature_files)
|
# print(feature_files)
|
||||||
for ff in feature_files:
|
for ff in feature_files:
|
||||||
webbrowser.open(os.path.join(
|
webbrowser.open(os.path.join(
|
||||||
runpath,
|
os.path.dirname(report_file),
|
||||||
"report",
|
|
||||||
ff + ".html"
|
ff + ".html"
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|||||||
@@ -153,7 +153,8 @@ if __name__ == "__main__":
|
|||||||
elif fea == "" and ifc != "":
|
elif fea == "" and ifc != "":
|
||||||
show_widget(fea, ifc, True, args)
|
show_widget(fea, ifc, True, args)
|
||||||
elif args["copyintemprun"]:
|
elif args["copyintemprun"]:
|
||||||
run.run_copyintmp_tests(args)
|
run.run_tests(args)
|
||||||
|
# TODO merge with else, but do not forget the tmp dir is not known
|
||||||
else:
|
else:
|
||||||
run.run_tests(args)
|
run.run_tests(args)
|
||||||
if args["report_after_run"]:
|
if args["report_after_run"]:
|
||||||
|
|||||||
Reference in New Issue
Block a user