1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
#!/bin/bash
#
# License:
# Zipios -- a small C++ library that provides easy access to .zip files.
#
# Copyright (c) 2015-2022 Made to Order Software Corp. All Rights Reserved
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
set -e
if test "$1" = "--help" -o "$1" = "-h"
then
echo "Usage: $0 [--opt] [test-name]"
echo "where --opt is one of:"
echo " --all run all tests"
echo " --full run all tests and publish to the world"
echo
echo "to run specific tests, use one of these tags (can be used with --full, but probably should not):"
echo " [directoryentry] run the DirectoryEntry class tests"
echo " [fileentry] run all the tests that check the FileEntry interface"
echo " [filepath] run the FilePath class tests"
echo
echo "for a complete list of tests use the --list command line option"
echo "of the test executable:"
echo " zipios_tests --list"
exit 1;
fi
if test "$1" = "--full"
then
FULL=true
shift
else
FULL=false
fi
start_date=`date`
SOURCE_PATH=`pwd`
. dev/version
echo "***"
echo "*** zipios coverage for version $FULL_VERSION (`date`)"
echo "***"
mkdir -p ../BUILD/zipios_coverage
rm -rf ../BUILD/zipios_coverage/*
cd ../BUILD
BUILD_PATH=`pwd`
cd zipios_coverage
# request coverage in this build
cmake -DCMAKE_INSTALL_PREFIX:PATH=$BUILD_PATH/dist \
-DCMAKE_BUILD_TYPE=Debug \
-Dzipios_project_COVERAGE:BOOL=ON \
-DCMAKE_MODULE_PATH:PATH=$SOURCE_PATH/cmake \
../../zipios
echo
echo "***"
echo "*** compile (`date`)"
echo "***"
VERBOSE=1 make
echo
echo "***"
echo "*** run (`date`)"
echo "***"
# todo:
# Catch does not give us such... we may want to bypass the limitation...
# For now I have a catch_version.cpp test at least
#if test `tests/zipios_tests --version` != "$FULL_VERSION"
#then
# echo "the version of zipios_tests (`BUILD/tests/zipios_tests --version`) is not equal to the project version ($FULL_VERSION)"
# exit 1;
#fi
if $FULL
then
# We test the pipe status on exit to detect whether the test failed
echo "Start running the tests on `date`" >test_log.txt
echo >>test_log.txt
# --success generates way too much output for HTML
tests/zipios_tests --source-path "${SOURCE_PATH}" --durations yes 2>&1 | tee -a test_log.txt; test ${PIPESTATUS[0]} -eq 0
echo >>test_log.txt
echo "Finished running the tests on `date`" >>test_log.txt
else
# "brief" test while working on a specific test
if test "$1" == "--all" -o -z "$1"
then
# Do it all, but not published
tests/zipios_tests --source-path "${SOURCE_PATH}"
else
tests/zipios_tests --source-path "${SOURCE_PATH}" $1
fi
# just in case, remove the log file if there is one
rm -f test_log.txt
fi
cd ..
echo
echo "***"
echo "*** gcov/lcov (`date`)"
echo "***"
# The following lcov options can be used under Ubuntu 14.04+
# Use --no-external and --base-directory $SOURCE_PATH
# to avoid /usr/include and other unwanted files
# (only available in lcov version 1.10+)
lcov --capture --no-external --directory zipios_coverage --base-directory $SOURCE_PATH --output-file coverage.info
mkdir -p zipios_coverage_html
genhtml --legend --demangle-cpp --no-branch-coverage --show-details coverage.info --output-directory zipios_coverage_html
end_date=`date`
# Statistics
echo "<html><head><title>zipios $FULL_VERSION statistics</title></head><body>" >zipios_coverage_html/statistics.html
echo "<h3>Statistics of the zipios $FULL_VERSION code</h3><pre>" >>zipios_coverage_html/statistics.html
cloc $SOURCE_PATH/src/ $SOURCE_PATH/tools/ $SOURCE_PATH/zipios/ >>zipios_coverage_html/statistics.html
echo "</pre><h3>Statistics of the zipios $FULL_VERSION tests</h3><pre>" >>zipios_coverage_html/statistics.html
cloc $SOURCE_PATH/tests/ >>zipios_coverage_html/statistics.html
echo "</pre></body></html>" >>zipios_coverage_html/statistics.html
# Test output (Logs)
echo "<html><head><title>zipios $FULL_VERSION test logs</title></head><body><h3>Logs for the zipios $FULL_VERSION tests</h3><p>Tests started on $start_date and finished on $end_date</p><pre>" >zipios_coverage_html/test_log.html
if test -f zipios_coverage/test_log.txt
then
# If test_log.txt does not exist, the user got the logs in the
# console already
cat zipios_coverage/test_log.txt >>zipios_coverage_html/test_log.html
fi
echo "</pre></body></html>" >>zipios_coverage_html/test_log.html
if test -f zipios_coverage/test_log.txt
then
echo "***"
echo "*** publication to ... ($end_date)"
echo "***"
# For publication, if that directory does not exist, you probably don't
# have a website to display this data
if test -d /usr/clients/www/alexis.m2osw.com/public_html/zipios
then
mkdir -p /usr/clients/www/alexis.m2osw.com/public_html/zipios/documentation
cp -r zipios_coverage/doc/zipios-doc-*/* /usr/clients/www/alexis.m2osw.com/public_html/zipios/documentation/.
cp $SOURCE_PATH/dev/index.php /usr/clients/www/alexis.m2osw.com/public_html/zipios/.
mkdir -p /usr/clients/www/alexis.m2osw.com/public_html/zipios/zipios-$FULL_VERSION
cp -r zipios_coverage_html/* /usr/clients/www/alexis.m2osw.com/public_html/zipios/zipios-$FULL_VERSION/.
cp zipios_coverage_html/statistics.html /usr/clients/www/alexis.m2osw.com/public_html/zipios/zipios-$FULL_VERSION/.
fi
fi
echo "Process started on $start_date"
echo "Process finished on $end_date"
# vim: ts=4 sw=4 et
|