From b818774f6aed2238cb7500b4d5d3073f23d6c44b Mon Sep 17 00:00:00 2001 From: jgoppert Date: Wed, 4 Nov 2015 22:48:13 -0500 Subject: [PATCH] Work on format testing. --- .travis.yml | 8 +++++++- CMakeLists.txt | 13 ++++++++----- scripts/format.sh | 21 +++++++++++++++++++++ 3 files changed, 36 insertions(+), 6 deletions(-) create mode 100755 scripts/format.sh diff --git a/.travis.yml b/.travis.yml index 5ad6695ec6..631c927450 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,12 @@ language: c script: - - mkdir -p build && cd build && cmake -DCOVERALLS=ON -DCOVERALLS_UPLOAD=ON -DCMAKE_BUILD_TYPE=Debug .. && make && ctest -V && make coveralls + - mkdir -p build + - cd build + - cmake -DCOVERALLS=ON -DCOVERALLS_UPLOAD=ON -DCMAKE_BUILD_TYPE=Debug .. + - make + - make check_format + - ctest -V + - make coveralls env: global: - export COVERALLS_SERVICE_NAME=travis-ci diff --git a/CMakeLists.txt b/CMakeLists.txt index 50bfeebe45..80e163f20d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,6 @@ set(CMAKE_CXX_FLAGS -Wall -Weffc++ -Werror - -std=c++11 #-Wfatal-errors ) @@ -65,12 +64,16 @@ endif() add_subdirectory(test) add_custom_target(format - COMMAND astyle --recursive - ${CMAKE_SOURCE_DIR}/matrix/*.*pp - ${CMAKE_SOURCE_DIR}/test/*.*pp + COMMAND scripts/format.sh 1 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} VERBATIM - ) +) + +add_custom_target(check_format + COMMAND scripts/format.sh + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + VERBATIM +) set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) diff --git a/scripts/format.sh b/scripts/format.sh new file mode 100755 index 0000000000..f5faa735ec --- /dev/null +++ b/scripts/format.sh @@ -0,0 +1,21 @@ +#!/bin/bash +echo pwd:$PWD +format=$1 +format_wildcards=""" +./matrix/*.*pp +./test/*.*pp +""" + +if [[ $format ]] +then + echo formatting + astyle ${format_wildcards} +else + echo checking format + astyle --dry-run ${format_wildcards} | grep Formatted + if [[ $? -eq 0 ]] + then + echo need to format + exit 1 + fi +fi