Skip to content
Snippets Groups Projects
Commit 8c21ee3c authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Plumedcheck checks for astyle

Travis-ci job doing cppcheck also checks whether astyle
has been enforced.

See #215
parent 2813d759
No related branches found
No related tags found
No related merge requests found
...@@ -90,6 +90,8 @@ install: ...@@ -90,6 +90,8 @@ install:
- if test "$CPPCHECK" == yes ; then ./.travis/install.cppcheck $CPPCHECK_VERSION ; fi - if test "$CPPCHECK" == yes ; then ./.travis/install.cppcheck $CPPCHECK_VERSION ; fi
# for plumedcheck I need latest gawk # for plumedcheck I need latest gawk
- if test "$CPPCHECK" == yes ; then ./.travis/install.gawk 4.1.4 ; fi - if test "$CPPCHECK" == yes ; then ./.travis/install.gawk 4.1.4 ; fi
# for plumedcheck I need astyle
- if test "$CPPCHECK" == yes ; then make -j 4 -C astyle ; fi
# installation of these packages takes a lot of time # installation of these packages takes a lot of time
# we do it only when needed # we do it only when needed
- if test "$PLUMED_CXX" == "mpic++" -a "$TRAVIS_OS_NAME" == "linux" ; then sudo apt-get install -y libopenmpi-dev openmpi-bin ; fi - if test "$PLUMED_CXX" == "mpic++" -a "$TRAVIS_OS_NAME" == "linux" ; then sudo apt-get install -y libopenmpi-dev openmpi-bin ; fi
......
...@@ -22,9 +22,9 @@ done ...@@ -22,9 +22,9 @@ done
if [ $do_plumedcheck == true ] ; then if [ $do_plumedcheck == true ] ; then
if [ $do_local == true ] ; then if [ $do_local == true ] ; then
../maketools/plumedcheck *.{h,cpp} ../../configure.ac ../maketools/plumedcheck *.{h,cpp} ../../configure.ac --astyle=../../astyle/astyle --astyle-options=../../.astyle.options
else else
maketools/plumedcheck --global-check */*.{h,cpp} ../configure.ac maketools/plumedcheck --global-check */*.{h,cpp} ../configure.ac --astyle=../astyle/astyle --astyle-options=../.astyle.options
fi fi
fi fi
......
...@@ -66,6 +66,7 @@ BEGIN{ ...@@ -66,6 +66,7 @@ BEGIN{
newargv[0]=ARGV[0] newargv[0]=ARGV[0]
pre="" pre=""
opt_global_check=0 opt_global_check=0
astyle="astyle"
for(i=1;i<ARGC;i++){ for(i=1;i<ARGC;i++){
opt=pre ARGV[i] opt=pre ARGV[i]
pre="" pre=""
...@@ -75,6 +76,14 @@ BEGIN{ ...@@ -75,6 +76,14 @@ BEGIN{
usage(); break; usage(); break;
case "--global-check": case "--global-check":
opt_global_check=1; break; opt_global_check=1; break;
case /--astyle=.*/:
sub("^--astyle=","",opt);
astyle=opt;
case /--astyle-options=.*/:
sub("^--astyle-options=","",opt);
astyle_options=opt;
break;
break;
case /-.*/: case /-.*/:
print "Unknown option " opt; exit(1) print "Unknown option " opt; exit(1)
default: default:
...@@ -129,6 +138,9 @@ BEGIN{ ...@@ -129,6 +138,9 @@ BEGIN{
core_modules["core"]=1 core_modules["core"]=1
core_modules["tools"]=1 core_modules["tools"]=1
core_modules["reference"]=1 core_modules["reference"]=1
# create tmp dir for future usage
"mktemp -d" | getline tmpdir
} }
# for each input file # for each input file
...@@ -182,6 +194,14 @@ BEGINFILE{ ...@@ -182,6 +194,14 @@ BEGINFILE{
# checks that are done only on some modules will be skipped if the module name is not known # checks that are done only on some modules will be skipped if the module name is not known
if((filetype=="source" || filetype=="header") && !module) information("missing_module_name","module name is not know, some check will be skipped"); if((filetype=="source" || filetype=="header") && !module) information("missing_module_name","module name is not know, some check will be skipped");
if(filetype=="source" || filetype=="header"){
tempfile = tmpdir "/astyle"
system(astyle " --options=" astyle_options " < " FILENAME " > " tempfile)
s=system("diff -q " FILENAME " " tempfile ">/dev/null 2>/dev/null")
if(s!=0) error("astyle","astyle not satisfied")
system("rm " tempfile)
}
} }
# line by line analysis # line by line analysis
...@@ -526,6 +546,9 @@ END{ ...@@ -526,6 +546,9 @@ END{
error("unused_has","has " has " at " plumed_definehas[has] " is not used") error("unused_has","has " has " at " plumed_definehas[has] " is not used")
} }
} }
# remove temporary directory
system("rmdir " tmpdir);
} }
EOF EOF
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment