SHARE
TWEET

Untitled

a guest Jun 19th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. FailedTestsDir="FailedTests"
  3. ListFailedTests="ListFailedTests.txt"
  4.  
  5.  
  6. DoCompile()
  7.    {
  8.       local CC=g++-4.4
  9.       local GCC_ARG="-lm -O1"
  10.    
  11.       local FileName=$1
  12.       local OutName=$2
  13.       $CC $FileName ${GCC_ARG} -o $OutName 2>>/dev/null
  14.       if [ -f $OutName ]
  15.       then
  16.          return 1
  17.       else
  18.          return 0
  19.       fi
  20.    }
  21.    
  22. OutPutResult()
  23.    {
  24.       echo
  25.       if [ "$(ls -A $FailedTestsDir)" ]
  26.       then
  27.          echo "Some tests are failed. You can find it in $FailedTestsDir"
  28.          echo "List of failed tests:"
  29.          cat $FailedTestsDir/$ListFailedTests
  30.       else
  31.          echo "All tests are passed!"
  32.      rm -r $FailedTestsDir
  33.       fi
  34.    }
  35.    
  36. DoInit()
  37.    {
  38.       if [ -d $FailedTestsDir ]; then
  39.          rm -r $FailedTestsDir
  40.       fi
  41.      
  42.       local Path
  43.       local PathToHeader="/home/void/devel/cppvs/H2/def.h"
  44.       for Path in `find ./ -type d`; do
  45.          if [ $Path == "./" ]; then
  46.         continue
  47.      fi
  48.      cp $PathToHeader $Path
  49.       done
  50.      
  51.       mkdir $FailedTestsDir    
  52.       touch $FailedTestsDir/$ListFailedTests
  53.    }
  54.  
  55. main()
  56.    {
  57.       local FilePath
  58.       local outname
  59.       local MustCompileSuffix="t"
  60.       local MustNOTCompileSuffix="x"
  61.      
  62.       DoInit
  63.      
  64.       for FilePath in `find ./ -iname '*.cc'`; do
  65.          outname=${FilePath%.cc}.out
  66.      local FileName=`expr "$FilePath" : '.*\(\/[[:alnum:]_~ -.]*$\)'`
  67.          FirstChar=${FileName:1:1}
  68.      
  69.      DoCompile $FilePath $outname
  70.      let OutNameExist=$?
  71.      
  72.          if [ $FirstChar = $MustNOTCompileSuffix -a $OutNameExist -eq 1 ] ||
  73.         [ $FirstChar = $MustCompileSuffix -a $OutNameExist -eq 0 ]
  74.          then
  75.             echo -e "\e[0;31mFile ${FilePath} FAILS!!!\e[0m"
  76.         cp $FilePath $FailedTestsDir
  77.             echo $FilePath >> $FailedTestsDir/$ListFailedTests
  78.      else
  79.         echo -e "\e[0;32mFile ${FilePath} - OK\e[0m"
  80.          fi
  81.      
  82.      if [ -f $outname ]
  83.      then
  84.         rm $outname
  85.      fi
  86.       done
  87.      
  88.       OutPutResult
  89.       return 0
  90.    }
  91.  
  92. main $@
  93. exit $?
RAW Paste Data
Top