Skip to content

Commit

Permalink
Merge branch 'master' into 10807_improve_filename_run_no_logging_indi…
Browse files Browse the repository at this point in the history
…rect

Conflicts:
	Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/JumpFit.py

Re #11649
  • Loading branch information
DanNixon committed Jun 15, 2015
2 parents 90a6410 + 2fc6d61 commit 63e926f
Show file tree
Hide file tree
Showing 1,473 changed files with 132,174 additions and 44,121 deletions.
125 changes: 125 additions & 0 deletions Code/Mantid/Build/CMake/Coveralls.cmake
@@ -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()



24 changes: 24 additions & 0 deletions Code/Mantid/Build/CMake/CoverallsClear.cmake
@@ -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)

145 changes: 145 additions & 0 deletions Code/Mantid/Build/CMake/CoverallsGenerateGcov.py
@@ -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:])
6 changes: 6 additions & 0 deletions Code/Mantid/Build/CMake/FindPyQt.py
Expand Up @@ -28,6 +28,10 @@ def get_qt4_tag(sip_flags):
else:
in_t = False
raise ValueError('Cannot find Qt\'s tag in PyQt4\'s SIP flags.')

def get_pyuic():
pyqt4_dir = os.path.dirname(PyQt4.__file__)
return os.path.join(pyqt4_dir, 'uic', 'pyuic.py')

if __name__ == '__main__':
try:
Expand All @@ -40,9 +44,11 @@ def get_qt4_tag(sip_flags):
# configure.py, so pyqtconfig.py is not installed.
sip_dir = get_default_sip_dir()
sip_flags = PyQt4.QtCore.PYQT_CONFIGURATION['sip_flags']
pyqt_pyuic = get_pyuic()

print('pyqt_version:%06.x' % PyQt4.QtCore.PYQT_VERSION)
print('pyqt_version_str:%s' % PyQt4.QtCore.PYQT_VERSION_STR)
print('pyqt_version_tag:%s' % get_qt4_tag(sip_flags))
print('pyqt_sip_dir:%s' % sip_dir)
print('pyqt_sip_flags:%s' % sip_flags)
print('pyqt_pyuic:%s' % pyqt_pyuic)
4 changes: 4 additions & 0 deletions Code/Mantid/Build/CMake/FindPyQt4.cmake
Expand Up @@ -49,6 +49,10 @@ ELSE(EXISTS PYQT4_VERSION)

STRING(REGEX MATCH ".*\npyqt_sip_flags:([^\n]+).*$" _dummy ${pyqt_config})
SET(PYQT4_SIP_FLAGS "${CMAKE_MATCH_1}" CACHE STRING "The SIP flags used to build PyQt4")

STRING(REGEX MATCH ".*\npyqt_pyuic:([^\n]+).*$" _dummy ${pyqt_config})
SET(PYQT4_PYUIC "${CMAKE_MATCH_1}" CACHE STRING "Location of the pyuic script")


IF(NOT IS_DIRECTORY "${PYQT4_SIP_DIR}")
MESSAGE(WARNING "The base directory where PyQt4's SIP files are installed could not be determined. This usually means PyQt4 was built with its new build system and pyqtconfig.py is not present.\n"
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Build/CMake/FindQwt.cmake
Expand Up @@ -18,7 +18,7 @@ find_package_handle_standard_args( Qwt DEFAULT_MSG QWT_LIBRARY QWT_INCLUDE_DIR )

# Parse version string from qwt_global.h
file ( STRINGS ${QWT_INCLUDE_DIR}/qwt_global.h QWT_VERSION
REGEX "^#define[ \t]+QWT_VERSION_STR[ \t]+\"[0-9]+.[0-9]+.[0-9]+\"$" )
REGEX "^#define[ \t]+QWT_VERSION_STR[ \t]+\"[0-9]+.[0-9]+.[0-9]+(.*)?\"$" )
if ( NOT QWT_VERSION )
message ( FATAL_ERROR "Unrecognized Qwt version (cannot find QWT_VERSION_STR in qwt_global.h)" )
endif()
Expand Down
29 changes: 29 additions & 0 deletions Code/Mantid/Build/CMake/GNUSetup.cmake
Expand Up @@ -14,6 +14,11 @@ elseif ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
message( STATUS "clang version ${CMAKE_CXX_COMPILER_VERSION}" )
endif()

#Use the old ABI until the dust has settled and all dependencies are built with the new ABI.
if ( CMAKE_COMPILER_IS_GNUCXX AND NOT (GCC_COMPILER_VERSION VERSION_LESS "5.1.0"))
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
endif()

# Global warning flags.
set( GNUFLAGS "-Wall -Wextra -Wconversion -Winit-self -Wpointer-arith -Wcast-qual -Wcast-align -fno-common" )
# Disable some warnings about deprecated headers and type conversions that
Expand All @@ -37,9 +42,33 @@ endif()
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-omit-frame-pointer" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer" )

option(WITH_ASAN "Enable address sanitizer" OFF)
if(WITH_ASAN)
message(STATUS "enabling address sanitizer")
add_compile_options(-fno-omit-frame-pointer -fno-common -fsanitize=address)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address -lasan" )
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -lasan" )
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address -lasan" )
endif()

option(WITH_UBSAN "Enable undefined behavior sanitizer" OFF)
if(WITH_UBSAN)
message(STATUS "enabling undefined behavior sanitizers")
set( UBSAN_NO_RECOVER "-fno-sanitize-recover")
if ( CMAKE_COMPILER_IS_GNUCXX AND GCC_COMPILER_VERSION VERSION_LESS "5.1.0")
set( UBSAN_NO_RECOVER "")
endif()
set(SAN_FLAGS "-fno-omit-frame-pointer -fno-common -fsanitize=undefined ${UBSAN_NO_RECOVER}")
add_compile_options(-fno-omit-frame-pointer -fno-common -fsanitize=undefined ${UBSAN_NO_RECOVER})
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${SAN_FLAGS}" )
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SAN_FLAGS}" )
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SAN_FLAGS}" )
endif()

# Set the options for gcc and g++
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GNUFLAGS}" )
# -Wno-overloaded-virtual is down here because it's not applicable to the C_FLAGS
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GNUFLAGS} -Woverloaded-virtual -fno-operator-names -std=c++0x" )

# Cleanup
set ( GNUFLAGS )

0 comments on commit 63e926f

Please sign in to comment.