Skip to content

Modified output.py to take a new argument and travis yml to use include for coveralls #1020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ script:
- 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'
- docker exec client python ./test/functional/setup/cleanup_dbs.py -dbname $SQLSRV_DBNAME
- docker exec client python ./test/functional/setup/cleanup_dbs.py -dbname $PDOSQLSRV_DBNAME
- docker exec client coveralls -e ./source/shared/ --gcov-options '\-lp'
- docker exec client coveralls -i ./source/ -e ./source/shared/ -e ./test/ --gcov-options '\-lp'
- docker stop client
- docker ps -a

Expand Down
33 changes: 23 additions & 10 deletions test/functional/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
# Requirement of python 3.4 to execute this script and required result log file(s)
# are in the same location
# Run with command line without options required. Example: py output.py
# This script parse output of PHP Native Test
# This script parse output of PHP Test logs
#
#############################################################################################

import os
import stat
import re
import argparse

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

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

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

# Generating the nativeresult.xml file.
file = open('nativeresult' + str(number) + '.xml', 'w')
# Generating the xml report.
if logfilename is True:
file = open(filename + '.xml', 'w')
else:
file = open('nativeresult' + str(number) + '.xml', 'w')

file.write('<?xml version="1.0" encoding="UTF-8" ?>' + os.linesep)
file.write('<testsuite tests="' + str(num - 1) + '" failures="' + str(failnum) + '" name="Native Tests" >' + os.linesep)

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

# ----------------------- Main Function -----------------------

# Display results on screen from result log file.
# Generate XML reports from test result log files.
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--LOGFILENAME', action='store_true', help="Generate XML files using log file names (default: False)")

args = parser.parse_args()
logfilename = args.LOGFILENAME

num = 1
for f in os.listdir(os.path.dirname(os.path.realpath(__file__))):
if f.endswith("log"):
logfile = f
gen_XML(logfile, num)
gen_XML(logfile, num, logfilename)
num = num + 1