Debian Codegraph @

lib/autotest/specific.m4

raw
1 # This file is part of Autoconf. -*- Autoconf -*-
2 # M4 macros used in running tests using third-party testing tools.
3 m4_define([_AT_COPYRIGHT_YEARS],
4 [Copyright (C) 2009-2017, 2020-2026 Free Software Foundation, Inc.])
5
6 # This file is part of Autoconf. This program is free
7 # software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the
9 # Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # Under Section 7 of GPL version 3, you are granted additional
18 # permissions described in the Autoconf Configure Script Exception,
19 # version 3.0, as published by the Free Software Foundation.
20 #
21 # You should have received a copy of the GNU General Public License
22 # and a copy of the Autoconf Configure Script Exception along with
23 # this program; see the files COPYINGv3 and COPYING.EXCEPTION
24 # respectively. If not, see <https://www.gnu.org/licenses/> and
25 # <https://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob_plain;f=COPYING.EXCEPTION>.
26
27
28 ## ------------------------ ##
29 ## Erlang EUnit unit tests. ##
30 ## ------------------------ ##
31
32 # AT_CHECK_EUNIT(MODULE, SPEC, [ERLFLAGS], [RUN-IF-FAIL], [RUN-IF-PASS])
33 # ----------------------------------------------------------------------
34 # Check that the EUnit test specification SPEC passes. The ERLFLAGS
35 # optional flags are passed to the Erlang interpreter command line to
36 # execute the test. The test is executed from an automatically
37 # generated Erlang module named MODULE. Each call to this macro should
38 # have a distinct MODULE name within each test group, to ease
39 # debugging.
40 # An Erlang/OTP version which contains the eunit library must be
41 # installed, in order to execute this macro in a test suite. The ERL,
42 # ERLC, and ERLCFLAGS variables must be defined in atconfig,
43 # typically by using the AC_ERLANG_PATH_ERL and AC_ERLANG_PATH_ERLC
44 # Autoconf macros.
45 _AT_DEFINE_SETUP([AT_CHECK_EUNIT],
46 [AT_SKIP_IF([test ! -f "$ERL" || test ! -f "$ERLC"])
47 ## A wrapper to EUnit, to exit the Erlang VM with the right exit code:
48 AT_DATA([$1.erl],
49 [[-module($1).
50 -export([test/0, test/1]).
51 test() -> test([]).
52 test(Options) ->
53 TestSpec = $2,
54 ReturnValue = case code:load_file(eunit) of
55 {module, _} -> case eunit:test(TestSpec, Options) of
56 ok -> "0\n"; %% test passes
57 _ -> "1\n" %% test fails
58 end;
59 _ -> "77\n" %% EUnit not found, test skipped
60 end,
61 file:write_file("$1.result", ReturnValue),
62 init:stop().
63 ]])
64 AT_CHECK(["$ERLC" $ERLCFLAGS -b beam $1.erl])
65 ## Make EUnit verbose when testsuite is verbose:
66 if test -z "$at_verbose"; then
67 at_eunit_options="verbose"
68 else
69 at_eunit_options=""
70 fi
71 AT_CHECK(["$ERL" $3 -s $1 test $at_eunit_options -noshell], [0], [ignore], [],
72 [$4], [$5])
73 AT_CAPTURE_FILE([$1.result])
74 AT_CHECK([test -f "$1.result" && (exit `cat "$1.result"`)])
75 ])