-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 10807_improve_filename_run_no_logging_indi…
…rect Conflicts: Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/JumpFit.py Re #11649
- Loading branch information
Showing
1,473 changed files
with
132,174 additions
and
44,121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
# | ||
# Copyright (C) 2014 Joakim Söderberg <joakim.soderberg@gmail.com> | ||
# | ||
|
||
|
||
# | ||
# Param _COVERAGE_SRCS A list of source files that coverage should be collected for. | ||
# Param _COVERALLS_UPLOAD Upload the result to coveralls? | ||
# | ||
function(coveralls_setup _COVERAGE_SRCS _COVERALLS_UPLOAD) | ||
|
||
if (ARGC GREATER 2) | ||
set(_CMAKE_SCRIPT_PATH ${ARGN}) | ||
message("Coveralls: Using alternate CMake script dir: ${_CMAKE_SCRIPT_PATH}") | ||
else() | ||
set(_CMAKE_SCRIPT_PATH ${PROJECT_SOURCE_DIR}/cmake) | ||
endif() | ||
|
||
if (NOT EXISTS "${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake") | ||
message(FATAL_ERROR "Coveralls: Missing ${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake") | ||
endif() | ||
|
||
if (NOT EXISTS "${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.py") | ||
message(FATAL_ERROR "Coveralls: Missing ${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.py") | ||
endif() | ||
|
||
#pass name to a file instead of a list of every source. | ||
set(COVERAGE_SRCS ${_COVERAGE_SRCS}) | ||
|
||
set(COVERALLS_FILE ${PROJECT_BINARY_DIR}/coveralls.json) | ||
|
||
find_package(Git) | ||
execute_process( | ||
COMMAND ${GIT_EXECUTABLE} rev-parse --show-toplevel | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
OUTPUT_VARIABLE PROJECT_ROOT | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
INCLUDE(FindPythonInterp) | ||
add_custom_target(coveralls_generate | ||
|
||
# Zero the coverage counters. | ||
COMMAND ${CMAKE_COMMAND} | ||
-P "${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake" | ||
|
||
# Run regression tests. Continue even if tests fail. | ||
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure || true | ||
|
||
# Generate Gcov and translate it into coveralls JSON. | ||
# We do this by executing an external CMake script. | ||
# (We don't want this to run at CMake generation time, but after compilation and everything has run). | ||
COMMAND ${PYTHON_EXECUTABLE} | ||
${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.py | ||
--COVERAGE_SRCS_FILE="${COVERAGE_SRCS}" | ||
--COVERALLS_OUTPUT_FILE="${COVERALLS_FILE}" | ||
--COV_PATH="${PROJECT_BINARY_DIR}" | ||
--PROJECT_ROOT="${PROJECT_ROOT}" | ||
|
||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR} | ||
COMMENT "Generating coveralls output..." | ||
) | ||
|
||
if (_COVERALLS_UPLOAD) | ||
message("COVERALLS UPLOAD: ON") | ||
|
||
find_program(CURL_EXECUTABLE curl) | ||
|
||
if (NOT CURL_EXECUTABLE) | ||
message(FATAL_ERROR "Coveralls: curl not found! Aborting") | ||
endif() | ||
|
||
add_custom_target(coveralls_upload | ||
# Upload the JSON to coveralls. | ||
COMMAND ${CURL_EXECUTABLE} | ||
-S -F json_file=@${COVERALLS_FILE} | ||
https://coveralls.io/api/v1/jobs | ||
|
||
DEPENDS coveralls_generate | ||
|
||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR} | ||
COMMENT "Uploading coveralls output...") | ||
|
||
add_custom_target(coveralls DEPENDS coveralls_upload) | ||
else() | ||
message("COVERALLS UPLOAD: OFF") | ||
add_custom_target(coveralls DEPENDS coveralls_generate) | ||
endif() | ||
|
||
endfunction() | ||
|
||
macro(coveralls_turn_on_coverage) | ||
if(NOT (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) | ||
AND (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")) | ||
message(FATAL_ERROR "Coveralls: Compiler ${CMAKE_C_COMPILER_ID} is not GNU gcc! Aborting... You can set this on the command line using CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake <options> ..") | ||
endif() | ||
|
||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
message(FATAL_ERROR "Coveralls: Code coverage results with an optimised (non-Debug) build may be misleading! Add -DCMAKE_BUILD_TYPE=Debug") | ||
endif() | ||
|
||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") | ||
endmacro() | ||
|
||
|
||
|
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,24 @@ | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
# | ||
# Copyright (C) 2014 Joakim Söderberg <joakim.soderberg@gmail.com> | ||
# | ||
|
||
file(REMOVE_RECURSE ${PROJECT_BINARY_DIR}/*.gcda) | ||
|
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,145 @@ | ||
import json | ||
import os | ||
import sys | ||
import getopt | ||
import subprocess | ||
import re | ||
import copy | ||
import hashlib | ||
|
||
def getBranchName(directory): | ||
"""Returns the name of the current git branch""" | ||
return subprocess.check_output(["git","rev-parse","--abbrev-ref","HEAD"],cwd=directory).strip() | ||
|
||
def getRemotes(directory): | ||
"""Returns list of remote git repositories""" | ||
gitRemoteOutput = subprocess.check_output(['git','remote','-v'],cwd=directory) | ||
remotes = [] | ||
for line in gitRemoteOutput.splitlines(): | ||
if '(fetch)' in line: | ||
splitLine = line.split(); | ||
remotes.append({'name': splitLine[0].strip(), 'url': splitLine[1].strip()}) | ||
return remotes | ||
|
||
def gitLogValue(format,directory): | ||
"""Returns git log value specified by format""" | ||
return subprocess.check_output(["git","log","-1","--pretty=format:%"+format],cwd=directory).strip() | ||
|
||
def getAllFilesWithExtension(directory,extension): | ||
"""Recursively return a list of all files in directory with specified extension""" | ||
filesWithExtension = [] | ||
for root, dirs, files in os.walk(directory): | ||
for file in files: | ||
if file.endswith(extension): | ||
filesWithExtension.append(os.path.realpath(os.path.join(root, file))) | ||
return filesWithExtension | ||
|
||
def getSourcePathFromGcovFile(gcovFilename): | ||
"""Return the source path corresponding to a .gcov file""" | ||
gcovPath,gcovFilenameWithExtension = os.path.split(gcovFilename) | ||
srcFilename = re.sub(".gcov$","",gcovFilenameWithExtension) | ||
return re.sub("#","/",srcFilename) | ||
|
||
def main(argv): | ||
arguments = ['COVERAGE_SRCS_FILE=','COVERALLS_OUTPUT_FILE=','COV_PATH=','PROJECT_ROOT='] | ||
COVERAGE_SRCS_FILE=None | ||
COVERALLS_OUTPUT_FILE=None | ||
COV_PATH=None | ||
PROJECT_ROOT=None | ||
optlist, args = getopt.getopt(argv,'',arguments) | ||
|
||
for o, a in optlist: | ||
if o == "--COVERAGE_SRCS_FILE": | ||
COVERAGE_SRCS_FILE=a | ||
elif o == "--COVERALLS_OUTPUT_FILE": | ||
COVERALLS_OUTPUT_FILE=a | ||
elif o == "--COV_PATH": | ||
COV_PATH=a | ||
elif o == "--PROJECT_ROOT": | ||
PROJECT_ROOT=a | ||
else: | ||
assert False, "unhandled option" | ||
|
||
if COVERAGE_SRCS_FILE == None: | ||
assert False, "COVERAGE_SRCS_FILE is not defined" | ||
if COVERALLS_OUTPUT_FILE==None: | ||
assert False, "COVERALLS_OUTPUT_FILE is not defined" | ||
if COV_PATH==None: | ||
assert False, "COV_PATH is not defined" | ||
if PROJECT_ROOT==None: | ||
assert False, "PROJECT_ROOT is not defined" | ||
|
||
gcdaAllFiles = getAllFilesWithExtension(COV_PATH,".gcda") | ||
for gcdaFile in gcdaAllFiles: | ||
gcdaDirectory = os.path.dirname(gcdaFile) | ||
subprocess.check_call(["gcov","-p","-o",gcdaDirectory,gcdaFile],cwd=COV_PATH) | ||
|
||
gcovAllFiles = getAllFilesWithExtension(COV_PATH,".gcov") | ||
|
||
sourcesToCheck = [line.strip() for line in open(COVERAGE_SRCS_FILE, 'r')] | ||
|
||
gcovCheckedFiles = [] | ||
uncheckedSources = sourcesToCheck | ||
for gcovFile in gcovAllFiles: | ||
sourceWithPath = getSourcePathFromGcovFile(gcovFile) | ||
if sourceWithPath in sourcesToCheck: | ||
print "YES: ",sourceWithPath.strip()," WAS FOUND" | ||
gcovCheckedFiles.append(gcovFile) | ||
uncheckedSources.remove(sourceWithPath) | ||
else: | ||
print "NO: ",sourceWithPath.strip()," WAS NOT FOUND" | ||
|
||
coverageList = [] | ||
for gcovFilename in gcovCheckedFiles: | ||
fileCoverage = {} | ||
#get name for json file | ||
sourceWithPath = getSourcePathFromGcovFile(gcovFilename) | ||
fileCoverage['name'] = os.path.relpath(sourceWithPath,PROJECT_ROOT) | ||
print "Generating JSON file for "+fileCoverage['name'] | ||
fileCoverage['source_digest'] = hashlib.md5(open(sourceWithPath, 'rb').read()).hexdigest() | ||
lineCoverage = [] | ||
gcovFile = open(gcovFilename,'r') | ||
for line in gcovFile: | ||
line = [i.strip() for i in line.split(':')] | ||
lineNumber = int(line[1]) | ||
if lineNumber != 0: | ||
if line[0] == '#####': | ||
lineCoverage.append(0) | ||
elif line[0] == '-': | ||
lineCoverage.append(None) | ||
else: | ||
lineCoverage.append(int(line[0])) | ||
if lineNumber != len(lineCoverage): | ||
raise RuntimeError['line_number does not match len(array)'] | ||
gcovFile.close() | ||
fileCoverage['coverage'] = lineCoverage | ||
coverageList.append(copy.deepcopy(fileCoverage)) | ||
|
||
for uncheckedFilename in uncheckedSources: | ||
fileCoverage = {} | ||
fileCoverage['name'] = os.path.relpath(uncheckedFilename,PROJECT_ROOT) | ||
fileCoverage['source_digest'] = hashlib.md5(open(uncheckedFilename, 'rb').read()).hexdigest() | ||
lineCoverage = [] | ||
uncheckedFile = open(uncheckedFilename,'r') | ||
for line in uncheckedFile: | ||
lineCoverage.append(0) | ||
uncheckedFile.close() | ||
fileCoverage['coverage'] = lineCoverage | ||
coverageList.append(copy.deepcopy(fileCoverage)) | ||
|
||
coverallsOutput = {} | ||
coverallsOutput['repo_token'] = os.environ.get('COVERALLS_REPO_TOKEN') | ||
coverallsOutput['source_files'] = coverageList | ||
|
||
head = {'id':gitLogValue('H',PROJECT_ROOT),'author_name':gitLogValue('an',PROJECT_ROOT), \ | ||
'author_email':gitLogValue('ae',PROJECT_ROOT),'committer_name':gitLogValue('cn',PROJECT_ROOT), \ | ||
'committer_email':gitLogValue('ce',PROJECT_ROOT), 'message':gitLogValue('B',PROJECT_ROOT)} | ||
|
||
gitDict = {'head':head,'branch':getBranchName(PROJECT_ROOT),'remotes':getRemotes(COV_PATH)} | ||
coverallsOutput['git'] = gitDict | ||
|
||
with open(COVERALLS_OUTPUT_FILE, 'w') as outfile: | ||
json.dump(coverallsOutput,outfile,indent=4) | ||
|
||
if __name__ == "__main__": | ||
main(sys.argv[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
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
Oops, something went wrong.