File: verify_compilation_error.sh

package info (click to toggle)
trompeloeil-cpp 47-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,476 kB
  • sloc: cpp: 17,573; sh: 126; makefile: 5
file content (41 lines) | stat: -rwxr-xr-x 940 bytes parent folder | download
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
#!/bin/sh

#
# Trompeloeil C++ mocking framework
#
# Copyright Björn Fahller 2022
#
#  Use, modification and distribution is subject to the
#  Boost Software License, Version 1.0. (See accompanying
#  file LICENSE_1_0.txt or copy at
#  http://www.boost.org/LICENSE_1_0.txt)
#
# Project home: https://github.com/rollbear/trompeloeil
#

get_rule ()
{
SCRIPT='
s|^// '$1': \(.*\)$|\1|g
t print
b
:print
P
'
sed -n "$SCRIPT" < $2
}
PASS="\033[32mPASS\033[0m"
FAIL="\033[1;31mFAIL\033[0m"

f=$1
EXCEPTION_RE=`get_rule "exception" $f`
COMPILER="${CXX} ${CXXFLAGS} ${CPPFLAGS}"

[ -n "$EXCEPTION_RE" ] && echo "{$RUNNER_OS} ${COMPILER}" | grep -q -e "$EXCEPTION_RE" && exit 0
PASS_RE=`get_rule "pass" $f`
failfile=`mktemp`
(${COMPILER} -I ../include $f -c 2>&1) > $failfile
cat $failfile | egrep  -q "${PASS_RE}" && printf "%-45s ${PASS}\n" $f && continue || { printf "%-45s ${FAIL}\n" $f; cat $failfile; } && false
RET=$?
rm $failfile
exit $RET