-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #251 from palexster/apa/release
Build release containers
- Loading branch information
Showing
9 changed files
with
146 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import re | ||
from junit_xml import TestSuite, TestCase | ||
import itertools | ||
|
||
|
||
|
||
def file_log_parser(file:str) -> dict: | ||
with open(file) as file_log: | ||
config = file_log.read() | ||
test_logs_results = {} | ||
index = "" | ||
for line in config.split("\n"): | ||
if "++++Starting test" in line: | ||
index = line.split(" ")[-1][:-4] | ||
test_logs_results[index] = "" | ||
elif "++++TEST" in line: | ||
index = "" | ||
elif index: | ||
test_logs_results[index] += line + "\n" | ||
return test_logs_results | ||
|
||
def create_junit_test_file(tests_file:str): | ||
tests = [] | ||
for file in tests_file.split("\n"): | ||
file_log = "test_log_" + "_".join(file.split("_")[2:]) | ||
test = file_log_parser(file_log) | ||
with open(file) as file_buffer: # Use file to refer to the file object | ||
config = file_buffer.read() | ||
current_section = {} | ||
lines = config.split() | ||
date = lines[1] | ||
is_relaunch = lines[2] | ||
debug=lines[3] | ||
for _,test_name,status,_,_,duration in zip(*[iter(lines[6:])]*6): | ||
if duration == "false": | ||
continue | ||
else: | ||
duration=duration[:-1] | ||
if test_name in test: | ||
tc = TestCase(name=test_name, elapsed_sec=int(duration),status=status.split("+")[0], stdout=test[test_name]) | ||
if status != "Passed++++": | ||
tc.add_failure_info(output=test[test_name]) | ||
else: | ||
tc = TestCase(name=test_name, elapsed_sec=int(duration), status=status.split("+")[0]) | ||
tests.append(tc) | ||
return tests | ||
|
||
def write_junit_file(output_file:str, tests:[], test_name:str) -> None: | ||
# We create a TestSUite and we write them in a XML File | ||
t = TestSuite(name=test_name,test_cases=tests) | ||
with open('output.xml', 'w') as f: | ||
TestSuite.to_file(f, [t], prettyprint=False) | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from converter import create_junit_test_file, write_junit_file | ||
import assertpy | ||
|
||
# content of test_sample.py | ||
|
||
def test_count_single_file_1(): | ||
t = create_junit_test_file("test_results_1.txt") | ||
assertpy.assert_that(len(t)).is_equal_to(10) | ||
|
||
def test_count_single_file_2(): | ||
t = create_junit_test_file("test_results_1.txt\ntest_results_2.txt") | ||
assertpy.assert_that(len(t)).is_equal_to(29) | ||
|
||
def test_assert_status_1(): | ||
t = create_junit_test_file("test_results_1.txt") | ||
for test in t: | ||
assertpy.assert_that(test.status).is_equal_to("Failed") | ||
|
||
def test_assert_status_2(): | ||
t = create_junit_test_file("test_results_2.txt") | ||
for test in t: | ||
assertpy.assert_that(test.status).is_equal_to("Passed") | ||
|
||
def test_failure_1(): | ||
t = create_junit_test_file("test_results_1.txt") | ||
assertpy.assert_that(len(t)).is_equal_to(10) | ||
for test in t: | ||
assertpy.assert_that(test.is_failure()).is_not_none() | ||
|
||
def test_not_failure_1(): | ||
t = create_junit_test_file("test_results_2.txt") | ||
assertpy.assert_that(len(t)).is_equal_to(19) | ||
for test in t: | ||
assertpy.assert_that(test.is_failure()).is_none() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
assertpy==0.15 | ||
pytest==5.3.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,13 @@ | ||
import re | ||
from junit_xml import TestSuite, TestCase | ||
import itertools | ||
import os | ||
import argparse | ||
import os | ||
from converter import create_junit_test_file, write_junit_file | ||
|
||
parser = argparse.ArgumentParser(description='Test File') | ||
parser.add_argument('test_suite_name', type=str, help='Class of tests to parse') | ||
args = parser.parse_args() | ||
OUTPUT_FILE = 'output.xml' | ||
TESTS_FILE = os.environ['TEST_RESULTS'] | ||
|
||
tests = [] | ||
|
||
def file_log_parser(file:str) -> dict: | ||
with open(file) as file_log: | ||
config = file_log.read() | ||
test_logs_results = {} | ||
index = "" | ||
for line in config.split("\n"): | ||
if "++++Starting test" in line: | ||
index = line.split(" ")[-1][:-4] | ||
test_logs_results[index] = "" | ||
elif "++++TEST" in line: | ||
index = "" | ||
elif index: | ||
test_logs_results[index] += line + "\n" | ||
return test_logs_results | ||
|
||
# For each test we generate a testCase parsing the output file | ||
for file in TESTS_FILE.split("\n"): | ||
file_log = "test_log_" + "_".join(file.split("_")[2:]) | ||
test = file_log_parser(file_log) | ||
with open(file) as file_buffer: # Use file to refer to the file object | ||
config = file_buffer.read() | ||
current_section = {} | ||
lines = config.split() | ||
date = lines[1] | ||
is_relaunch = lines[2] | ||
debug=lines[3] | ||
for _,test_name,status,_,_,duration in zip(*[iter(lines[6:])]*6): | ||
if duration == "false": | ||
continue | ||
else: | ||
duration=duration[:-1] | ||
if test_name in test: | ||
tc = TestCase(name=test_name, elapsed_sec=int(duration),status=status, stdout=test[test_name]) | ||
else: | ||
tc = TestCase(name=test_name, elapsed_sec=int(duration),status=status) | ||
tests.append(tc) | ||
|
||
# We create a TestSUite and we write them in a XML File | ||
t = TestSuite(name=args.test_suite_name,test_cases=tests) | ||
with open('output.xml', 'w') as f: | ||
TestSuite.to_file(f, [t], prettyprint=False) | ||
if __name__ == "__main__": | ||
tests = create_junit_test_file(TESTS_FILE) | ||
write_junit_file(OUTPUT_FILE,tests,args.test_suite_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters