Skip to content

Commit

Permalink
add key TESTDIR in build.json which points to location of test.
Browse files Browse the repository at this point in the history
This is used with buildtest build run to locate test directory location.
Enable module permutation feature (build -m <MODULE>)  to work with test configuration.
buildtest can generate a test script per module version. Name of test will
be random hex decimal.
  • Loading branch information
shahzebsiddiqui committed Oct 30, 2019
1 parent 0abfb1c commit 489ae0c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
18 changes: 14 additions & 4 deletions src/buildtest/tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from datetime import datetime
import json
import os
import random
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -65,9 +66,11 @@ def func_build_subcmd(args):
system["OS_VERSION"],
f"build_{str(build_id)}")



config_opts['BUILDTEST_TESTDIR'] = os.path.join(config_opts['BUILDTEST_TESTDIR'],test_subdir)
create_dir(config_opts['BUILDTEST_TESTDIR'])

BUILDTEST_BUILD_HISTORY[build_id]["TESTDIR"] = config_opts['BUILDTEST_TESTDIR']

logger, LOGFILE = init_log()
logger.info(f"Opening File: {BUILDTEST_SYSTEM} and loading as JSON object")
Expand Down Expand Up @@ -105,9 +108,16 @@ def func_build_subcmd(args):
singlesource_test = SingleSource(file)
content = singlesource_test.build_test_content()
logger.info("Injecting method to inject modules into test script")
content["module"] = module_selector(args.collection,args.module_collection)

write_test(content,args.verbose)
if args.modules:
for x in module_cmd_list:
content["module"] = []
content["module"].append(x)
dirname = os.path.dirname(content['testpath'])
content["testpath"] = '%s.exe' % os.path.join(dirname,hex(random.getrandbits(32)))
write_test(content, args.verbose)
else:
content["module"] = module_selector(args.collection,args.module_collection)
write_test(content,args.verbose)


# if binary test is True then generate binary test for all loaded modules
Expand Down
3 changes: 2 additions & 1 deletion src/buildtest/tools/buildsystem/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def run_tests(args):
tests = content["build"][str(args.id)]["TESTS"]

# all tests are in same directory, retrieving parent directory of test
test_dir = os.path.dirname(tests[0])
test_dir = content["build"][str(args.id)]["TESTDIR"]

runfile = datetime.now().strftime("buildtest_%H_%M_%d_%m_%Y.run")
run_output_file = os.path.join(test_dir,"run",runfile)
Expand All @@ -92,6 +92,7 @@ def run_tests(args):
count_test = len(tests)
passed_test = 0
failed_test = 0

for test in tests:
ret = subprocess.Popen(test,
shell=True,
Expand Down
2 changes: 1 addition & 1 deletion src/buildtest/tools/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ def write_test(dict,verbose):
print (line)
print ("{:_<80}".format(""))

BUILDTEST_BUILD_HISTORY[build_id]["TESTS"] = [dict["testpath"]]
BUILDTEST_BUILD_HISTORY[build_id]["TESTS"].append(dict["testpath"])

0 comments on commit 489ae0c

Please sign in to comment.