Prefer HTTPS to FTP and HTTP
[autoconf.git] / lib / autotest / specific.m4
blobd747314df56f0e31f562824ee190ceef53e68394
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 Free Software Foundation, Inc.])
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.
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.
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.
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/>.
27 ## ------------------------ ##
28 ## Erlang EUnit unit tests. ##
29 ## ------------------------ ##
31 # AT_CHECK_EUNIT(MODULE, SPEC, [ERLFLAGS], [RUN-IF-FAIL], [RUN-IF-PASS])
32 # ----------------------------------------------------------------------
33 # Check that the EUnit test specification SPEC passes. The ERLFLAGS
34 # optional flags are passed to the Erlang interpreter command line to
35 # execute the test. The test is executed from an automatically
36 # generated Erlang module named MODULE. Each call to this macro should
37 # have a distinct MODULE name within each test group, to ease
38 # debugging.
39 # An Erlang/OTP version which contains the eunit library must be
40 # installed, in order to execute this macro in a test suite.  The ERL,
41 # ERLC, and ERLCFLAGS variables must be defined in atconfig,
42 # typically by using the AC_ERLANG_PATH_ERL and AC_ERLANG_PATH_ERLC
43 # Autoconf macros.
44 _AT_DEFINE_SETUP([AT_CHECK_EUNIT],
45 [AT_SKIP_IF([test ! -f "$ERL" || test ! -f "$ERLC"])
46 ## A wrapper to EUnit, to exit the Erlang VM with the right exit code:
47 AT_DATA([$1.erl],
48 [[-module($1).
49 -export([test/0, test/1]).
50 test() -> test([]).
51 test(Options) ->
52   TestSpec = $2,
53   ReturnValue = case code:load_file(eunit) of
54     {module, _} -> case eunit:test(TestSpec, Options) of
55         ok -> "0\n"; %% test passes
56         _  -> "1\n"  %% test fails
57       end;
58     _ -> "77\n" %% EUnit not found, test skipped
59   end,
60   file:write_file("$1.result", ReturnValue),
61   init:stop().
62 ]])
63 AT_CHECK(["$ERLC" $ERLCFLAGS -b beam $1.erl])
64 ## Make EUnit verbose when testsuite is verbose:
65 if test -z "$at_verbose"; then
66   at_eunit_options="verbose"
67 else
68   at_eunit_options=""
70 AT_CHECK(["$ERL" $3 -s $1 test $at_eunit_options -noshell], [0], [ignore], [],
71          [$4], [$5])
72 AT_CAPTURE_FILE([$1.result])
73 AT_CHECK([test -f "$1.result" && (exit `cat "$1.result"`)])