Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/bash
0002 
0003 #
0004 # Licensed to the Apache Software Foundation (ASF) under one or more
0005 # contributor license agreements.  See the NOTICE file distributed with
0006 # this work for additional information regarding copyright ownership.
0007 # The ASF licenses this file to You under the Apache License, Version 2.0
0008 # (the "License"); you may not use this file except in compliance with
0009 # the License.  You may obtain a copy of the License at
0010 #
0011 #    http://www.apache.org/licenses/LICENSE-2.0
0012 #
0013 # Unless required by applicable law or agreed to in writing, software
0014 # distributed under the License is distributed on an "AS IS" BASIS,
0015 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0016 # See the License for the specific language governing permissions and
0017 # limitations under the License.
0018 #
0019 
0020 FWDIR="$(cd `dirname $0`; pwd)"
0021 
0022 FAILED=0
0023 LOGFILE=$FWDIR/unit-tests.out
0024 rm -f $LOGFILE
0025 
0026 SPARK_TESTING=1 NOT_CRAN=true $FWDIR/../bin/spark-submit --driver-java-options "-Dlog4j.configuration=file:$FWDIR/log4j.properties" --conf spark.hadoop.fs.defaultFS="file:///" --conf spark.driver.extraJavaOptions="-Dio.netty.tryReflectionSetAccessible=true" --conf spark.executor.extraJavaOptions="-Dio.netty.tryReflectionSetAccessible=true" $FWDIR/pkg/tests/run-all.R 2>&1 | tee -a $LOGFILE
0027 FAILED=$((PIPESTATUS[0]||$FAILED))
0028 
0029 NUM_TEST_WARNING="$(grep -c -e 'Warnings ----------------' $LOGFILE)"
0030 
0031 # Also run the documentation tests for CRAN
0032 CRAN_CHECK_LOG_FILE=$FWDIR/cran-check.out
0033 rm -f $CRAN_CHECK_LOG_FILE
0034 
0035 NO_TESTS=1 NO_MANUAL=1 $FWDIR/check-cran.sh 2>&1 | tee -a $CRAN_CHECK_LOG_FILE
0036 FAILED=$((PIPESTATUS[0]||$FAILED))
0037 
0038 NUM_CRAN_WARNING="$(grep -c WARNING$ $CRAN_CHECK_LOG_FILE)"
0039 NUM_CRAN_ERROR="$(grep -c ERROR$ $CRAN_CHECK_LOG_FILE)"
0040 NUM_CRAN_NOTES="$(grep -c NOTE$ $CRAN_CHECK_LOG_FILE)"
0041 HAS_PACKAGE_VERSION_WARN="$(grep -c "Insufficient package version" $CRAN_CHECK_LOG_FILE)"
0042 
0043 if [[ $FAILED != 0 || $NUM_TEST_WARNING != 0 ]]; then
0044     cat $LOGFILE
0045     echo -en "\033[31m"  # Red
0046     echo "Had test warnings or failures; see logs."
0047     echo -en "\033[0m"  # No color
0048     exit -1
0049 else
0050     # We have 2 NOTEs: for RoxygenNote and one in Jenkins only "No repository set"
0051     # For non-latest version branches, one WARNING for package version
0052     if [[ ($NUM_CRAN_WARNING != 0 || $NUM_CRAN_ERROR != 0 || $NUM_CRAN_NOTES -gt 2) &&
0053           ($HAS_PACKAGE_VERSION_WARN != 1 || $NUM_CRAN_WARNING != 1 || $NUM_CRAN_ERROR != 0 || $NUM_CRAN_NOTES -gt 1) ]]; then
0054       cat $CRAN_CHECK_LOG_FILE
0055       echo -en "\033[31m"  # Red
0056       echo "Had CRAN check errors; see logs."
0057       echo -en "\033[0m"  # No color
0058       exit -1
0059     else
0060       echo -en "\033[32m"  # Green
0061       echo "Tests passed."
0062       echo -en "\033[0m"  # No color
0063     fi
0064 fi