Merge pull request #597 from yitam/codecov
Analyse coverage only in 2016
This commit is contained in:
commit
0a30d49941
154
appveyor.yml
154
appveyor.yml
|
@ -1,5 +1,5 @@
|
|||
version: '{branch}.{build}'
|
||||
|
||||
|
||||
branches:
|
||||
# whitelist
|
||||
#only:
|
||||
|
@ -17,63 +17,63 @@ environment:
|
|||
PDOSQLSRV_DBNAME: msphpsql_pdosqlsrv
|
||||
PHP_DEPSVER: 7.0
|
||||
PHP_SDK: c:\projects\php
|
||||
matrix:
|
||||
matrix:
|
||||
- BUILD_PLATFORM: x86
|
||||
TEST_PHP_SQL_SERVER: (local)\SQL2016
|
||||
SQL_INSTANCE: SQL2016
|
||||
PHP_VC: 14
|
||||
PHP_MAJOR_VER: 7.1
|
||||
PHP_MINOR_VER: latest
|
||||
PHP_MINOR_VER: latest
|
||||
PHP_SDK_DIR: c:\projects\php\x86
|
||||
PHP_INSTALL_DIR: c:\projects\php\x86\bin
|
||||
PHP_INSTALL_DIR: c:\projects\php\x86\bin
|
||||
PHP_ZTS: --disable-zts
|
||||
platform: x86
|
||||
- BUILD_PLATFORM: x86
|
||||
- BUILD_PLATFORM: x64
|
||||
TEST_PHP_SQL_SERVER: (local)\SQL2012SP1
|
||||
SQL_INSTANCE: SQL2012SP1
|
||||
PHP_VC: 14
|
||||
PHP_MAJOR_VER: 7.0
|
||||
PHP_MINOR_VER: latest
|
||||
PHP_SDK_DIR: c:\projects\php\x86
|
||||
PHP_INSTALL_DIR: c:\projects\php\x86\bin
|
||||
PHP_ZTS: --disable-zts
|
||||
platform: x86
|
||||
- BUILD_PLATFORM: x86
|
||||
PHP_MINOR_VER: latest
|
||||
PHP_SDK_DIR: c:\projects\php\x64
|
||||
PHP_INSTALL_DIR: c:\projects\php\x64\bin
|
||||
platform: x64
|
||||
- BUILD_PLATFORM: x64
|
||||
TEST_PHP_SQL_SERVER: (local)\SQL2014
|
||||
SQL_INSTANCE: SQL2014
|
||||
PHP_VC: 14
|
||||
PHP_MAJOR_VER: 7.0
|
||||
PHP_MAJOR_VER: 7.1
|
||||
PHP_MINOR_VER: latest
|
||||
PHP_SDK_DIR: c:\projects\php\x86
|
||||
PHP_INSTALL_DIR: c:\projects\php\x86\bin
|
||||
platform: x86
|
||||
PHP_SDK_DIR: c:\projects\php\x64
|
||||
PHP_INSTALL_DIR: c:\projects\php\x64\bin
|
||||
platform: x64
|
||||
- BUILD_PLATFORM: x86
|
||||
TEST_PHP_SQL_SERVER: (local)\SQL2008R2SP2
|
||||
SQL_INSTANCE: SQL2008R2SP2
|
||||
PHP_VC: 14
|
||||
PHP_MAJOR_VER: 7.1
|
||||
PHP_MAJOR_VER: 7.0
|
||||
PHP_MINOR_VER: latest
|
||||
PHP_SDK_DIR: c:\projects\php\x86
|
||||
PHP_INSTALL_DIR: c:\projects\php\x86\bin
|
||||
PHP_ZTS: --disable-zts
|
||||
platform: x86
|
||||
|
||||
|
||||
# PHP_MAJOR_VER is PHP major version to build (7.0, 7.1)
|
||||
# PHP_MINOR_VER is PHP point release number (or latest for latest release)
|
||||
# PHP_MINOR_VER is PHP point release number (or latest for latest release)
|
||||
# PHP_INSTALL_DIR is where the built PHP binaries go
|
||||
# PHP_SDK_DIR is where PHP source is extracted to (e.g. PHP_SDK_DIR\php-7.0.14-src)
|
||||
# PHP_SDK is where PHP sdk binary tools are extracted to
|
||||
# PHP_VC is the Visual C++ version
|
||||
# PHP_ZTS is defined to disable thread safe build
|
||||
|
||||
|
||||
# Build worker image (VM template)
|
||||
image: Visual Studio 2015
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
|
||||
#services:
|
||||
#- mssql2012sp1
|
||||
|
||||
|
||||
# clone directory (or %APPVEYOR_BUILD_FOLDER%)
|
||||
clone_folder: c:\projects\sqlphp
|
||||
|
||||
|
@ -102,12 +102,12 @@ install:
|
|||
# determine latest PHP versions
|
||||
- ps: >-
|
||||
If ($env:PHP_MINOR_VER -Match "latest") {
|
||||
$env:PHP_VERSION=type sha1sum.txt | where { $_ -match "php-($env:PHP_MAJOR_VER\.\d+)-src" } | foreach { $matches[1] } ;
|
||||
$env:PHP_VERSION=type sha1sum.txt | where { $_ -match "php-($env:PHP_MAJOR_VER\.\d+)-src" } | foreach { $matches[1] } ;
|
||||
} Else {
|
||||
$env:PHP_VERSION=$env:PHP_MAJOR_VER + '.' + $env:PHP_MINOR_VER;
|
||||
}
|
||||
- echo Downloading PHP-SDK
|
||||
- appveyor DownloadFile http://windows.php.net/downloads/php-sdk/php-sdk-binary-tools-20110915.zip
|
||||
- appveyor DownloadFile http://windows.php.net/downloads/php-sdk/php-sdk-binary-tools-20110915.zip
|
||||
- move php-sdk-binary-tools-20110915.zip ..
|
||||
- echo Downloading PHP source code [%PHP_VERSION%]
|
||||
- ps: (new-object net.webclient).DownloadFile('http://windows.php.net/downloads/releases/php-' + ${env:PHP_VERSION} + '-src.zip', ${env:APPVEYOR_BUILD_FOLDER} + '\..\php.zip')
|
||||
|
@ -115,7 +115,7 @@ install:
|
|||
# AppVeyor build works are x64 VMs and 32-bit ODBC driver cannot be installed on it
|
||||
- ps: (new-object net.webclient).DownloadFile('https://download.microsoft.com/download/D/5/E/D5EEF288-A277-45C8-855B-8E2CB7E25B96/x64/msodbcsql.msi', 'c:\projects\msodbcsql.msi')
|
||||
- cmd /c start /wait msiexec /i "c:\projects\msodbcsql.msi" /q
|
||||
- echo Checking the version of MSODBCSQL
|
||||
- echo Checking the version of MSODBCSQL
|
||||
- reg query "HKLM\SOFTWARE\ODBC\odbcinst.ini\ODBC Driver 13 for SQL Server"
|
||||
- dir C:\Windows\System32\msodbcsql13.dll
|
||||
- cd ..
|
||||
|
@ -127,31 +127,29 @@ install:
|
|||
- ps: Get-Content ${env:APPVEYOR_BUILD_FOLDER}\test\functional\pdo_sqlsrv\MsSetup.inc
|
||||
- ps: (Get-Content ${env:APPVEYOR_BUILD_FOLDER}\test\functional\sqlsrv\MsSetup.inc) | ForEach-Object { $_ -replace "TARGET_SERVER", ${env:TEST_PHP_SQL_SERVER} -replace "TARGET_DATABASE", ${env:SQLSRV_DBNAME} -replace "TARGET_USERNAME", ${env:TEST_PHP_SQL_UID} -replace "TARGET_PASSWORD", ${env:TEST_PHP_SQL_PWD} } | Set-Content ${env:APPVEYOR_BUILD_FOLDER}\test\functional\sqlsrv\MsSetup.inc
|
||||
- ps: Get-Content ${env:APPVEYOR_BUILD_FOLDER}\test\functional\sqlsrv\MsSetup.inc
|
||||
- appveyor DownloadFile http://github.com/OpenCppCoverage/OpenCppCoverage/releases/download/release-0.9.6.1/OpenCppCoverageSetup-x64-0.9.6.1.exe
|
||||
- OpenCppCoverageSetup-x64-0.9.6.1.exe /VERYSILENT
|
||||
- ps: ls "c:\Program Files"
|
||||
- set CPPCOVER="C:\\Program Files\\OpenCppCoverage"
|
||||
- set PATH=%CPPCOVER%;%PATH%
|
||||
|
||||
- echo install opencppcoverage
|
||||
- choco install opencppcoverage
|
||||
- set path=C:\Program Files\OpenCppCoverage;%path%
|
||||
|
||||
build_script:
|
||||
- '"C:\\Program Files (x86)\\Microsoft Visual Studio %PHP_VC%.0\\VC\\vcvarsall.bat" %BUILD_PLATFORM%'
|
||||
- Echo copy msphp code to ext folder
|
||||
- mkdir %PHP_SDK_DIR%\php-%PHP_VERSION%-src\ext\sqlsrv
|
||||
- mkdir %PHP_SDK_DIR%\php-%PHP_VERSION%-src\ext\sqlsrv\shared
|
||||
- mkdir %PHP_SDK_DIR%\php-%PHP_VERSION%-src\ext\pdo_sqlsrv
|
||||
- mkdir %PHP_SDK_DIR%\php-%PHP_VERSION%-src\ext\pdo_sqlsrv
|
||||
- mkdir %PHP_SDK_DIR%\php-%PHP_VERSION%-src\ext\pdo_sqlsrv\shared
|
||||
- copy /Y %APPVEYOR_BUILD_FOLDER%\source\sqlsrv %PHP_SDK_DIR%\php-%PHP_VERSION%-src\ext\sqlsrv
|
||||
- copy /Y %APPVEYOR_BUILD_FOLDER%\source\shared %PHP_SDK_DIR%\php-%PHP_VERSION%-src\ext\sqlsrv\shared
|
||||
- copy /Y %APPVEYOR_BUILD_FOLDER%\source\shared %PHP_SDK_DIR%\php-%PHP_VERSION%-src\ext\pdo_sqlsrv\shared
|
||||
- copy /Y %APPVEYOR_BUILD_FOLDER%\source\pdo_sqlsrv %PHP_SDK_DIR%\php-%PHP_VERSION%-src\ext\pdo_sqlsrv
|
||||
- copy /Y %APPVEYOR_BUILD_FOLDER%\source\pdo_sqlsrv %PHP_SDK_DIR%\php-%PHP_VERSION%-src\ext\pdo_sqlsrv
|
||||
- cd %PHP_SDK_DIR%\php-%PHP_VERSION%-src
|
||||
- cd
|
||||
- dir
|
||||
- dir
|
||||
- '%PHP_SDK%\bin\phpsdk_setvars.bat'
|
||||
- buildconf.bat
|
||||
# only build CLI and MSSQL extensions
|
||||
- configure.bat --disable-all %PHP_ZTS% --enable-cli --enable-sqlsrv=shared --with-pdo-sqlsrv=shared --enable-pdo=shared --with-prefix=%PHP_INSTALL_DIR%
|
||||
- copy php.ini-development php.ini
|
||||
- copy php.ini-development php.ini
|
||||
- echo extension_dir=%PHP_INSTALL_DIR%\ext >> php.ini
|
||||
- echo extension=php_sqlsrv.dll >> php.ini
|
||||
- echo extension=php_pdo_sqlsrv.dll >> php.ini
|
||||
|
@ -160,57 +158,67 @@ build_script:
|
|||
- Echo copy php.ini and run-tests.php from php source to install directory.
|
||||
- copy php.ini %PHP_INSTALL_DIR%
|
||||
- copy run-tests.php %PHP_INSTALL_DIR%
|
||||
- dir %PHP_INSTALL_DIR%
|
||||
- dir %PHP_INSTALL_DIR%
|
||||
|
||||
test_script:
|
||||
- cd %PHP_INSTALL_DIR%
|
||||
- cd %PHP_INSTALL_DIR%
|
||||
- php --ini
|
||||
- php -i
|
||||
- python -V
|
||||
- python -V
|
||||
- Echo setup test database for SQLSRV tests - %SQLSRV_DBNAME%
|
||||
- python %APPVEYOR_BUILD_FOLDER%\test\functional\setup\setup_dbs.py -dbname %SQLSRV_DBNAME%
|
||||
- Echo setup test database for PDO_SQLSRV tests - %PDOSQLSRV_DBNAME%
|
||||
- python %APPVEYOR_BUILD_FOLDER%\test\functional\setup\setup_dbs.py -dbname %PDOSQLSRV_DBNAME%
|
||||
- copy %APPVEYOR_BUILD_FOLDER%\source\shared\msodbcsql.h %APPVEYOR_BUILD_FOLDER%\test\functional\setup\
|
||||
- python %APPVEYOR_BUILD_FOLDER%\test\functional\setup\build_ksp.py
|
||||
- copy %APPVEYOR_BUILD_FOLDER%\test\functional\setup\*.dll %APPVEYOR_BUILD_FOLDER%\test\functional\sqlsrv\
|
||||
- copy %APPVEYOR_BUILD_FOLDER%\test\functional\setup\*.dll %APPVEYOR_BUILD_FOLDER%\test\functional\pdo_sqlsrv\
|
||||
- python %APPVEYOR_BUILD_FOLDER%\test\functional\setup\run_ksp.py -server %TEST_PHP_SQL_SERVER% -dbname %SQLSRV_DBNAME% -uid %TEST_PHP_SQL_UID% -pwd %TEST_PHP_SQL_PWD%
|
||||
- python %APPVEYOR_BUILD_FOLDER%\test\functional\setup\run_ksp.py -server %TEST_PHP_SQL_SERVER% -dbname %PDOSQLSRV_DBNAME% -uid %TEST_PHP_SQL_UID% -pwd %TEST_PHP_SQL_PWD%
|
||||
- php run-tests.php -p php.exe %APPVEYOR_BUILD_FOLDER%\test\functional\sqlsrv\*.phpt > %APPVEYOR_BUILD_FOLDER%\test\functional\sqlsrv.log 2>&1
|
||||
- type %APPVEYOR_BUILD_FOLDER%\test\functional\sqlsrv.log
|
||||
- php run-tests.php -p php.exe %APPVEYOR_BUILD_FOLDER%\test\functional\pdo_sqlsrv\*.phpt > %APPVEYOR_BUILD_FOLDER%\test\functional\pdo_sqlsrv.log 2>&1
|
||||
- type %APPVEYOR_BUILD_FOLDER%\test\functional\pdo_sqlsrv.log
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\test\functional\
|
||||
- ps: $difffiles = Get-ChildItem sqlsrv\*.diff
|
||||
- ps: $outfiles = Get-ChildItem sqlsrv\*.out
|
||||
- ps: foreach($file in $difffiles){ls $file; more $file}
|
||||
- ps: foreach($file in $outfiles){ls $file; more $file}
|
||||
- ps: $difffiles = Get-ChildItem pdo_sqlsrv\*.diff
|
||||
- ps: $outfiles = Get-ChildItem pdo_sqlsrv\*.out
|
||||
- ps: foreach($file in $difffiles){ls $file; more $file}
|
||||
- ps: foreach($file in $outfiles){ls $file; more $file}
|
||||
- cd %PHP_INSTALL_DIR%
|
||||
- OpenCppCoverage.exe --sources %PHP_SDK_DIR%\php-%PHP_VERSION%-src\ext\pdo_sqlsrv --sources %PHP_SDK_DIR%\php-%PHP_VERSION%-src\ext\sqlsrv --modules *sqlsrv*.dll --export_type=cobertura:.\coverage.xml --cover_children --quiet --continue_after_cpp_exception --optimized_build -- .\php.exe .\run-tests.php -P %APPVEYOR_BUILD_FOLDER%\test\functional\
|
||||
- ls
|
||||
#- copy %APPVEYOR_BUILD_FOLDER%\source\shared\msodbcsql.h %APPVEYOR_BUILD_FOLDER%\test\functional\setup\
|
||||
#- python %APPVEYOR_BUILD_FOLDER%\test\functional\setup\build_ksp.py
|
||||
#- copy %APPVEYOR_BUILD_FOLDER%\test\functional\setup\*.dll %APPVEYOR_BUILD_FOLDER%\test\functional\sqlsrv\
|
||||
#- copy %APPVEYOR_BUILD_FOLDER%\test\functional\setup\*.dll %APPVEYOR_BUILD_FOLDER%\test\functional\pdo_sqlsrv\
|
||||
#- python %APPVEYOR_BUILD_FOLDER%\test\functional\setup\run_ksp.py -server %TEST_PHP_SQL_SERVER% -dbname %SQLSRV_DBNAME% -uid %TEST_PHP_SQL_UID% -pwd %TEST_PHP_SQL_PWD%
|
||||
#- python %APPVEYOR_BUILD_FOLDER%\test\functional\setup\run_ksp.py -server %TEST_PHP_SQL_SERVER% -dbname %PDOSQLSRV_DBNAME% -uid %TEST_PHP_SQL_UID% -pwd %TEST_PHP_SQL_PWD%
|
||||
- ps: >-
|
||||
If ($env:SQL_INSTANCE -Match "SQL2016") {
|
||||
Write-Host "Running phpt tests via OpenCppCoverage..."
|
||||
$ext_dir = ${env:PHP_SDK_DIR} + "\php-" + ${env:PHP_VERSION} + "-src\ext";
|
||||
OpenCppCoverage.exe --sources $ext_dir\sqlsrv --sources $ext_dir\pdo_sqlsrv --modules ext\php_sqlsrv.dll --modules ext\php_pdo_sqlsrv.dll --export_type=cobertura:.\coverage.xml --quiet --cover_children --continue_after_cpp_exception --optimized_build -- .\php.exe run-tests.php -P ${env:APPVEYOR_BUILD_FOLDER}\test\functional\ | out-file -filePath ${env:APPVEYOR_BUILD_FOLDER}\test\functional\tests.log -encoding UTF8;
|
||||
type ${env:APPVEYOR_BUILD_FOLDER}\test\functional\tests.log;
|
||||
ls *.xml
|
||||
} Else {
|
||||
Write-Host "Running phpt tests the regular way..."
|
||||
.\php.exe run-tests.php -P ${env:APPVEYOR_BUILD_FOLDER}\test\functional\sqlsrv\*.phpt | out-file -filePath ${env:APPVEYOR_BUILD_FOLDER}\test\functional\sqlsrv.log -encoding UTF8;
|
||||
type ${env:APPVEYOR_BUILD_FOLDER}\test\functional\sqlsrv.log;
|
||||
.\php.exe run-tests.php -P ${env:APPVEYOR_BUILD_FOLDER}\test\functional\pdo_sqlsrv\*.phpt | out-file -filePath ${env:APPVEYOR_BUILD_FOLDER}\test\functional\pdo_sqlsrv.log -encoding UTF8;
|
||||
type ${env:APPVEYOR_BUILD_FOLDER}\test\functional\pdo_sqlsrv.log;
|
||||
}
|
||||
- python %APPVEYOR_BUILD_FOLDER%\test\functional\setup\cleanup_dbs.py -dbname %SQLSRV_DBNAME%
|
||||
- python %APPVEYOR_BUILD_FOLDER%\test\functional\setup\cleanup_dbs.py -dbname %PDOSQLSRV_DBNAME%
|
||||
- pip install codecov
|
||||
- codecov -f ".\coverage.xml"
|
||||
- cd %PHP_INSTALL_DIR%
|
||||
- ps: $fileExists = Test-Path "coverage.xml"
|
||||
- ps: >-
|
||||
If ($fileExists -eq $true) {
|
||||
Write-Host "Running coverage analysis...";
|
||||
$env:PATH = ${env:PHP_INSTALL_DIR} + $env:PATH;
|
||||
Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh
|
||||
bash codecov.sh -f "coverage.xml"
|
||||
}
|
||||
|
||||
after_test:
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\test\functional\
|
||||
- python output.py
|
||||
- ps: (new-object net.webclient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\nativeresult1.xml))
|
||||
- ps: (new-object net.webclient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\nativeresult2.xml))
|
||||
- ps: >-
|
||||
[xml]$results = Get-Content nativeresult1.xml ;
|
||||
[xml]$results2 = Get-Content nativeresult2.xml ;
|
||||
$failure = $results.SelectSingleNode("//failure");
|
||||
$failure2 = $results2.SelectSingleNode("//failure");
|
||||
if ($failure -ne $null -Or $failure2 -ne $null)
|
||||
{
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\test\functional\
|
||||
- ps: ls *.log
|
||||
- python output.py
|
||||
- ps: $difffiles = Get-ChildItem sqlsrv\*.diff
|
||||
- ps: $outfiles = Get-ChildItem sqlsrv\*.out
|
||||
- ps: foreach($file in $difffiles){ls $file; more $file}
|
||||
- ps: foreach($file in $outfiles){ls $file; more $file}
|
||||
- ps: $diff2files = Get-ChildItem pdo_sqlsrv\*.diff
|
||||
- ps: $out2files = Get-ChildItem pdo_sqlsrv\*.out
|
||||
- ps: foreach($file in $diff2files){ls $file; more $file}
|
||||
- ps: foreach($file in $out2files){ls $file; more $file}
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\test\functional\
|
||||
- ps: $xmlfiles = Get-ChildItem *.xml
|
||||
- ps: foreach($file in $xmlfiles){(new-object net.webclient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $file))}
|
||||
- ps: >-
|
||||
If ($difffiles -ne $null -Or $diff2files -ne $null) {
|
||||
$host.SetShouldExit(1);
|
||||
Write-Host "Forcing build failure due to phpt unit test failure(s)";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,136 +2,93 @@
|
|||
#########################################################################################
|
||||
#
|
||||
# Description:
|
||||
# Requirement of python 3.4 to execute this script and required result log file are in the same location
|
||||
# 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
|
||||
#
|
||||
#
|
||||
#############################################################################################
|
||||
|
||||
import os
|
||||
import stat
|
||||
import re
|
||||
|
||||
# This module returns either the number of test or the number of failed test
|
||||
# depending on the argument you requested.
|
||||
# Input: var - a single variable containing either "FAIL" or "TOTAL"
|
||||
# Output: Returns a number of test/s or failed test/s
|
||||
def returnCount(var):
|
||||
with open(os.path.dirname(os.path.realpath(__file__)) + os.sep + logfile) as f:
|
||||
num = 0
|
||||
failnum = 0
|
||||
for line in f:
|
||||
if "FAIL" in line or "PASS" in line:
|
||||
if ".phpt" in line:
|
||||
if "FAIL" in line:
|
||||
failnum += 1
|
||||
num += 1
|
||||
if var == 'total':
|
||||
return str(num)
|
||||
# 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
|
||||
# line - current line of the log file
|
||||
# index - the current index of tests
|
||||
# tests_list - a list of xml entries
|
||||
# get_title - boolean flag to get the test title or not
|
||||
# Output: None
|
||||
def get_test_entry(search_pattern, line, index, tests_list, get_title = False):
|
||||
# find the full path to the test name, enclosed by square brackets
|
||||
result = re.search(search_pattern, line)
|
||||
pos1 = result.group(1).find('[')
|
||||
pos2 = result.group(1).find(']')
|
||||
test_line = str(result.group(1))
|
||||
|
||||
# get the test name by splitting this full path delimited by os.sep
|
||||
substr = test_line[pos1+1:pos2]
|
||||
tmp_array = substr.split(os.sep)
|
||||
pos = len(tmp_array) - 1
|
||||
test_name = tmp_array[pos]
|
||||
|
||||
# only upon a failure do we get the test title
|
||||
if (get_title is True):
|
||||
entry = '\t<testcase name="' + test_name + '-' + index + '">'
|
||||
tests_list.append(entry)
|
||||
test_title = test_line[0:pos1]
|
||||
entry = '\t\t<failure message=" Failed in ' + test_title + '"/>'
|
||||
tests_list.append(entry)
|
||||
tests_list.append('\t</testcase>')
|
||||
else:
|
||||
return str(failnum)
|
||||
entry = '\t<testcase name="' + test_name + '-' + index + '"/>'
|
||||
tests_list.append(entry)
|
||||
|
||||
# This module prints the line that matches the expression.
|
||||
# Input: inputStr - String that matches
|
||||
# file - file name
|
||||
# path - path of the file.
|
||||
# Output: null
|
||||
def readAndPrint(inputStr, file, path):
|
||||
filn = open(path + os.sep + file).readlines()
|
||||
for lines in filn:
|
||||
if inputStr in lines:
|
||||
print(lines)
|
||||
|
||||
# This module returns the test file name.
|
||||
# Input: line - current line of the log file
|
||||
# Output: Returns the filename.
|
||||
def TestFilename(line):
|
||||
terminateChar = os.sep
|
||||
currentPos = 0
|
||||
firstpos = len(line) * -1
|
||||
while True:
|
||||
currentPos = currentPos - 1
|
||||
# if passed the first pos, stop
|
||||
if currentPos < firstpos:
|
||||
break
|
||||
line[currentPos]
|
||||
if line[currentPos] == terminateChar:
|
||||
break
|
||||
file = line[currentPos+1:-1]
|
||||
return file
|
||||
|
||||
def genXML(logfile,number):
|
||||
# Generating the nativeresult.xml file.
|
||||
file = open('nativeresult' + str(number) + '.xml','w')
|
||||
file.write('<?xml version="1.0" encoding="UTF-8" ?>' + os.linesep)
|
||||
file.write('<testsuite tests="' + returnCount('total') + '" failures="' + returnCount('fail') + '" name="Native Tests" >' + os.linesep)
|
||||
file.close()
|
||||
|
||||
# Extract individual test results from the log file and
|
||||
# enter it in the nativeresult.xml file.
|
||||
# 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):
|
||||
print('================================================')
|
||||
print("\n" + os.path.splitext(logfile)[0] + "\n" )
|
||||
|
||||
tests_list = []
|
||||
with open(os.path.dirname(os.path.realpath(__file__)) + os.sep + logfile) as f:
|
||||
num = 1
|
||||
failnum = 0
|
||||
for line in f:
|
||||
file = open('nativeresult' + str(number) + '.xml','a')
|
||||
if "FAIL" in line or "PASS" in line:
|
||||
if ".phpt" in line:
|
||||
|
||||
file.write('\t<testcase name="')
|
||||
if "FAIL" in line:
|
||||
failnum += 1
|
||||
result = re.search('FAIL(.*).', line)
|
||||
file.write(TestFilename(str(result.group(1))) + '-' + str(num) + '">' + os.linesep)
|
||||
stop_pos = result.group(1).find('[')
|
||||
file.write('\t\t<failure message=" Failed in ' + str(result.group(1))[0:stop_pos] + '"/>' + os.linesep)
|
||||
file.write('\t</testcase>' + os.linesep)
|
||||
get_test_entry('FAIL(.*).', line, str(num), tests_list, True)
|
||||
else:
|
||||
result = re.search('PASS(.*).', line)
|
||||
file.write(TestFilename(str(result.group(1))) + '-' + str(num) + '"/>' + os.linesep)
|
||||
get_test_entry('PASS(.*).', line, str(num), tests_list)
|
||||
num += 1
|
||||
file.close()
|
||||
elif 'Number of tests :' in line or 'Tests skipped ' in line or 'Tests warned ' in line or'Tests failed ' in line or 'Expected fail ' in line or 'Tests passed ' in line:
|
||||
print(line)
|
||||
print('================================================')
|
||||
|
||||
file = open('nativeresult' + str(number) + '.xml','a')
|
||||
file.write('</testsuite>' + os.linesep)
|
||||
file.close()
|
||||
# Generating the nativeresult.xml file.
|
||||
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)
|
||||
|
||||
def run():
|
||||
num = 1
|
||||
for f in os.listdir(os.path.dirname(os.path.realpath(__file__))):
|
||||
if f.endswith("log"):
|
||||
print('================================================')
|
||||
print(os.path.splitext(f)[0])
|
||||
readAndPrint('Number of tests :', f, os.path.dirname(os.path.realpath(__file__)))
|
||||
readAndPrint('Tests skipped ', f, os.path.dirname(os.path.realpath(__file__)))
|
||||
readAndPrint('Tests warned ', f, os.path.dirname(os.path.realpath(__file__)))
|
||||
readAndPrint('Tests failed ', f, os.path.dirname(os.path.realpath(__file__)))
|
||||
readAndPrint('Expected fail ', f, os.path.dirname(os.path.realpath(__file__)))
|
||||
readAndPrint('Tests passed ', f, os.path.dirname(os.path.realpath(__file__)))
|
||||
print('================================================')
|
||||
logfile = f
|
||||
genXML(logfile,num)
|
||||
num = num + 1
|
||||
index = 1
|
||||
for test in tests_list:
|
||||
file.write(test + os.linesep)
|
||||
file.write('</testsuite>' + os.linesep)
|
||||
file.close()
|
||||
|
||||
|
||||
# ------------------------------------------------------- Main Function ---------------------------------------------------
|
||||
# ----------------------- Main Function -----------------------
|
||||
|
||||
# Display results on screen from result log file.
|
||||
if __name__ == '__main__':
|
||||
num = 1
|
||||
for f in os.listdir(os.path.dirname(os.path.realpath(__file__))):
|
||||
if f.endswith("log"):
|
||||
print('================================================')
|
||||
print("\n" + os.path.splitext(f)[0] + "\n")
|
||||
readAndPrint('Number of tests :', f, os.path.dirname(os.path.realpath(__file__)))
|
||||
readAndPrint('Tests skipped ', f, os.path.dirname(os.path.realpath(__file__)))
|
||||
readAndPrint('Tests warned ', f, os.path.dirname(os.path.realpath(__file__)))
|
||||
readAndPrint('Tests failed ', f, os.path.dirname(os.path.realpath(__file__)))
|
||||
readAndPrint('Expected fail ', f, os.path.dirname(os.path.realpath(__file__)))
|
||||
readAndPrint('Tests passed ', f, os.path.dirname(os.path.realpath(__file__)))
|
||||
print('================================================')
|
||||
logfile = f
|
||||
genXML(logfile,num)
|
||||
gen_XML(logfile, num)
|
||||
num = num + 1
|
||||
|
||||
|
|
Loading…
Reference in a new issue