"Fossies" - the Fresh Open Source Software Archive

Member "ILIAS-5.4.9/run_tests_with_reporting.sh" (24 Jan 2020, 3184 Bytes) of package /linux/www/ILIAS-5.4.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 
    3 PRE="\t*** "
    4 
    5 function printLn() {
    6     echo -e "$PRE $1"
    7 }
    8 
    9 printLn "Initialize paths variables"
   10 
   11 PHPUNIT_PATH="/tmp/phpunit_latest.csv"
   12 PHPUNIT_PATH_TMP="/tmp/phpunit_changed.csv"
   13 PHPUNIT_RESULTS_PATH="/tmp/phpunit_results"
   14 DICTO_PATH="/tmp/dicto_latest.csv"
   15 TRAVIS_RESULTS_DIRECTORY="/tmp/CI-Results/"
   16 DATE=`date '+%Y-%m-%d %H:%M:%S'`
   17 UNIXDATE=`date '+%s'`
   18 
   19 ./run_tests.sh | tee "$PHPUNIT_RESULTS_PATH"
   20 
   21 PIPE_EXIT_CODE=`echo ${PIPESTATUS[0]}`
   22 
   23 printLn "Command exited with code: $PIPE_EXIT_CODE"
   24 
   25 printLn "Travis: event type ($TRAVIS_EVENT_TYPE), job number ($TRAVIS_JOB_NUMBER), pull request ($TRAVIS_PULL_REQUEST), commit ($TRAVIS_COMMIT) "
   26 
   27 if [[ -e "$PHPUNIT_RESULTS_PATH" ]]
   28     then
   29         printLn "Collecting data."
   30         RESULT=`tail -n1 < "$PHPUNIT_RESULTS_PATH"`
   31         SPLIT_RESULT=(`echo $RESULT | tr ':' ' '`)
   32         PHP_VERSION=`php -r "echo PHP_MAJOR_VERSION . '_' . PHP_MINOR_VERSION;"`
   33         if [ -e "include/inc.ilias_version.php" ]
   34             then
   35                 ILIAS_VERSION=`php -r "require_once 'include/inc.ilias_version.php'; echo ILIAS_VERSION_NUMERIC;"`
   36                 ILIAS_VERSION=`echo "$ILIAS_VERSION" | tr . _`
   37         fi
   38 
   39         JOB_ID=`echo $TRAVIS_JOB_NUMBER`
   40         JOB_URL=`echo $TRAVIS_JOB_WEB_URL`
   41         FAILURE=false
   42         declare -A RESULTS=([Tests]=0 [Assertions]=0 [Errors]=0 [Warnings]=0 [Skipped]=0 [Incomplete]=0 [Risky]=0 [Failures]=0);
   43 
   44         for TYPE in "${!RESULTS[@]}"; 
   45             do 
   46                 for PHP_UNIT_RESULT in "${!SPLIT_RESULT[@]}"; 
   47                     do 
   48                         if [ "$TYPE" == "${SPLIT_RESULT[$PHP_UNIT_RESULT]}" ]
   49                             then
   50                                 CLEANED=(`echo ${SPLIT_RESULT[$PHP_UNIT_RESULT + 1]} | tr ',.' ' '`)
   51                                 RESULTS[$TYPE]=$CLEANED;
   52                         fi
   53                     done 
   54             done
   55 
   56         if [ ${RESULTS[Errors]} -gt 0 ] || [ ${RESULTS[Failures]} -gt 0 ]
   57             then
   58                 FAILURE=true
   59         fi
   60 
   61         if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]
   62         then
   63             printLn "Cloning results repository, copy results file."
   64             if [ -d "$TRAVIS_RESULTS_DIRECTORY" ]; then
   65                 printLn "Starting to remove old temp directory"
   66                 rm -rf "$TRAVIS_RESULTS_DIRECTORY"
   67             fi
   68 
   69             cd /tmp && git clone https://github.com/ILIAS-eLearning/CI-Results
   70             cp "$TRAVIS_RESULTS_DIRECTORY/data/phpunit_latest.csv" "$PHPUNIT_PATH"
   71 
   72             printLn "Removing old line PHP version $PHP_VERSION and ILIAS version $ILIAS_VERSION"
   73             grep -v "$ILIAS_VERSION.*php_$PHP_VERSION" $PHPUNIT_PATH > $PHPUNIT_PATH_TMP 
   74 
   75             NEW_LINE="$JOB_URL,$JOB_ID,$ILIAS_VERSION,php_$PHP_VERSION,PHP $PHP_VERSION,${RESULTS[Warnings]},${RESULTS[Skipped]},${RESULTS[Incomplete]},${RESULTS[Tests]},${RESULTS[Errors]},${RESULTS[Risky]},$FAILURE,$DATE,$UNIXDATE";
   76             printLn "Writing line: $NEW_LINE"
   77             echo "$NEW_LINE" >> "$PHPUNIT_PATH_TMP";
   78 
   79             printLn "Handling result."
   80 
   81             if [ -e "$PHPUNIT_PATH_TMP" ]
   82                 then
   83                     mv "$PHPUNIT_PATH_TMP" "$PHPUNIT_PATH"
   84                     rm "$PHPUNIT_RESULTS_PATH"
   85             fi
   86 
   87             printLn "Switching directory and run results handling."
   88             cp "$PHPUNIT_PATH" "$TRAVIS_RESULTS_DIRECTORY/data/"
   89             cd "$TRAVIS_RESULTS_DIRECTORY" && ./run.sh
   90 
   91     fi      
   92     if [[ "$FAILURE" == "true" || $PIPE_EXIT_CODE -gt 0 ]]
   93         then
   94             printLn "Errors were found, exiting with error code."
   95             exit 99
   96     else
   97             printLn "No errors were found."
   98             exit 0
   99     fi
  100 else
  101     printLn "No result file found, stopping!"
  102     exit 99
  103 fi