Skip to content

Commit aa03782

Browse files
authored
Modified output.py to take a new argument and travis yml to use include for coveralls (#1020)
1 parent bae6930 commit aa03782

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ script:
4343
- docker exec client bash -c 'for f in ./test/functional/pdo_sqlsrv/*.out; do ls $f 2>/dev/null; cat $f 2>/dev/null; done || true'
4444
- docker exec client python ./test/functional/setup/cleanup_dbs.py -dbname $SQLSRV_DBNAME
4545
- docker exec client python ./test/functional/setup/cleanup_dbs.py -dbname $PDOSQLSRV_DBNAME
46-
- docker exec client coveralls -e ./source/shared/ --gcov-options '\-lp'
46+
- docker exec client coveralls -i ./source/ -e ./source/shared/ -e ./test/ --gcov-options '\-lp'
4747
- docker stop client
4848
- docker ps -a
4949

test/functional/output.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
# Requirement of python 3.4 to execute this script and required result log file(s)
66
# are in the same location
77
# Run with command line without options required. Example: py output.py
8-
# This script parse output of PHP Native Test
8+
# This script parse output of PHP Test logs
99
#
1010
#############################################################################################
1111

1212
import os
1313
import stat
1414
import re
15+
import argparse
1516

1617
# This module appends an entry to the tests list, may include the test title.
1718
# Input: search_pattern - pattern to look for in the line of the log file
@@ -46,12 +47,14 @@ def get_test_entry(search_pattern, line, index, tests_list, get_title = False):
4647
tests_list.append(entry)
4748

4849
# Extract individual test results from the log file and
49-
# enter it in the nativeresult.xml file.
50-
# Input: logfile - the log file
51-
# number - the number for this xml file
52-
def gen_XML(logfile, number):
50+
# enter it in the xml report file.
51+
# Input: logfile - the test log file
52+
# number - the number for this xml file (applicable if using the default report name)
53+
# logfilename - use the log file name for the xml output file Instead
54+
def gen_XML(logfile, number, logfilename):
5355
print('================================================')
54-
print("\n" + os.path.splitext(logfile)[0] + "\n" )
56+
filename = os.path.splitext(logfile)[0]
57+
print("\n" + filename + "\n" )
5558

5659
tests_list = []
5760
with open(os.path.dirname(os.path.realpath(__file__)) + os.sep + logfile) as f:
@@ -70,8 +73,12 @@ def gen_XML(logfile, number):
7073
print(line)
7174
print('================================================')
7275

73-
# Generating the nativeresult.xml file.
74-
file = open('nativeresult' + str(number) + '.xml', 'w')
76+
# Generating the xml report.
77+
if logfilename is True:
78+
file = open(filename + '.xml', 'w')
79+
else:
80+
file = open('nativeresult' + str(number) + '.xml', 'w')
81+
7582
file.write('<?xml version="1.0" encoding="UTF-8" ?>' + os.linesep)
7683
file.write('<testsuite tests="' + str(num - 1) + '" failures="' + str(failnum) + '" name="Native Tests" >' + os.linesep)
7784

@@ -83,12 +90,18 @@ def gen_XML(logfile, number):
8390

8491
# ----------------------- Main Function -----------------------
8592

86-
# Display results on screen from result log file.
93+
# Generate XML reports from test result log files.
8794
if __name__ == '__main__':
95+
parser = argparse.ArgumentParser()
96+
parser.add_argument('--LOGFILENAME', action='store_true', help="Generate XML files using log file names (default: False)")
97+
98+
args = parser.parse_args()
99+
logfilename = args.LOGFILENAME
100+
88101
num = 1
89102
for f in os.listdir(os.path.dirname(os.path.realpath(__file__))):
90103
if f.endswith("log"):
91104
logfile = f
92-
gen_XML(logfile, num)
105+
gen_XML(logfile, num, logfilename)
93106
num = num + 1
94107

0 commit comments

Comments
 (0)