Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- FailedTestsDir="FailedTests"
- ListFailedTests="ListFailedTests.txt"
- DoCompile()
- {
- local CC=g++-4.4
- local GCC_ARG="-lm -O1"
- local FileName=$1
- local OutName=$2
- $CC $FileName ${GCC_ARG} -o $OutName 2>>/dev/null
- if [ -f $OutName ]
- then
- return 1
- else
- return 0
- fi
- }
- OutPutResult()
- {
- echo
- if [ "$(ls -A $FailedTestsDir)" ]
- then
- echo "Some tests are failed. You can find it in $FailedTestsDir"
- echo "List of failed tests:"
- cat $FailedTestsDir/$ListFailedTests
- else
- echo "All tests are passed!"
- rm -r $FailedTestsDir
- fi
- }
- DoInit()
- {
- if [ -d $FailedTestsDir ]; then
- rm -r $FailedTestsDir
- fi
- local Path
- local PathToHeader="/home/void/devel/cppvs/H2/def.h"
- for Path in `find ./ -type d`; do
- if [ $Path == "./" ]; then
- continue
- fi
- cp $PathToHeader $Path
- done
- mkdir $FailedTestsDir
- touch $FailedTestsDir/$ListFailedTests
- }
- main()
- {
- local FilePath
- local outname
- local MustCompileSuffix="t"
- local MustNOTCompileSuffix="x"
- DoInit
- for FilePath in `find ./ -iname '*.cc'`; do
- outname=${FilePath%.cc}.out
- local FileName=`expr "$FilePath" : '.*\(\/[[:alnum:]_~ -.]*$\)'`
- FirstChar=${FileName:1:1}
- DoCompile $FilePath $outname
- let OutNameExist=$?
- if [ $FirstChar = $MustNOTCompileSuffix -a $OutNameExist -eq 1 ] ||
- [ $FirstChar = $MustCompileSuffix -a $OutNameExist -eq 0 ]
- then
- echo -e "\e[0;31mFile ${FilePath} FAILS!!!\e[0m"
- cp $FilePath $FailedTestsDir
- echo $FilePath >> $FailedTestsDir/$ListFailedTests
- else
- echo -e "\e[0;32mFile ${FilePath} - OK\e[0m"
- fi
- if [ -f $outname ]
- then
- rm $outname
- fi
- done
- OutPutResult
- return 0
- }
- main $@
- exit $?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement