This repository was archived by the owner on Oct 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathruntest.sh
More file actions
executable file
·102 lines (93 loc) · 2.62 KB
/
runtest.sh
File metadata and controls
executable file
·102 lines (93 loc) · 2.62 KB
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
#!/bin/bash
#
# This file is part of Lodel 2 (https://github.com/OpenEdition)
#
# Copyright (C) 2015-2017 Cléo UMS-3287
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3,
# as published by the Free Software Foundation.
#
# This program 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Usage : ./runtest [OPTIONS] [test_module[.test_class][ test_module2[.test_class2]...]
#########
#
# Running all discoverables tests :
# ./runtest
#
################
# -f, --failfast
#
# Stop the test run on the first error or failure.
# -v --verbose
#
# higher verbosity
#
# -d 0 : results are not displayed but stored in logfiles in /tmp/logXXXXXXX repository, with XXXXXXX a timestamp (default)
# -d 1 : results are displayed when tests finish and kept in logfiles in /tmp/logXXXXXXX repository, with XXXXXXX a timestamp
# -d 2 : results are displayed when tests finish, they are not stored
#
# Furthermore
################
# Most of the tests need an install of lodel for dependencies reasons
# For those which not need, prefix the python file by 'nc_' (example nc_test_query.py)
# they will be executed outside a lodel install
# More details :
################
#
# https://docs.python.org/3.4/library/unittest.html
#
if test ! -f lodel/buildconf.py
then
echo "You have to build the project before running the tests"
echo "See README"
exit 1
fi
logdisplay=2;
while getopts ":d:" opt; do
case $opt in
d)
logdisplay=$OPTARG
;;
:)
echo "Option -$OPTARG requires an argument, as it does not have we assume 0"
;;
esac
done
if [[ $logdisplay -eq 2 ]]
then
echo $logdisplay
logdir=$(mktemp -td "lodel2_log_unittest_XXXXXXX")
else
if [ ! -d ./tmp ]
then
mkdir ./tmp
fi
timestamp=$(date +%s)
logdir="$(dirname $(realpath $0))/tmp/log$timestamp"
mkdir $logdir
fi
PYTHON='env python3'
ret_status=0
$PYTHON ./nocontext_tests.py $logdir $@ || ret_status=1
./runtest_context.sh $logdir $@ || ret_status=1
if [[ $logdisplay -eq 1 || $logdisplay -eq 2 ]]
then
logfiles=$(ls $logdir)
for logfile in $logfiles
do
cat $logdir/$logfile
done
if [[ $logdisplay -eq 2 ]]
then
rm -rf $logdir
fi
fi
exit $ret_status