Blame lib/autotest/specific.m4

Packit Service 9646c7
# This file is part of Autoconf.                          -*- Autoconf -*-
Packit Service 9646c7
# M4 macros used in running tests using third-party testing tools.
Packit Service 9646c7
m4_define([_AT_COPYRIGHT_YEARS],
Packit Service 9646c7
[Copyright (C) 2009-2012 Free Software Foundation, Inc.])
Packit Service 9646c7
Packit Service 9646c7
# This file is part of Autoconf.  This program is free
Packit Service 9646c7
# software; you can redistribute it and/or modify it under the
Packit Service 9646c7
# terms of the GNU General Public License as published by the
Packit Service 9646c7
# Free Software Foundation, either version 3 of the License, or
Packit Service 9646c7
# (at your option) any later version.
Packit Service 9646c7
#
Packit Service 9646c7
# This program is distributed in the hope that it will be useful,
Packit Service 9646c7
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 9646c7
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 9646c7
# GNU General Public License for more details.
Packit Service 9646c7
#
Packit Service 9646c7
# Under Section 7 of GPL version 3, you are granted additional
Packit Service 9646c7
# permissions described in the Autoconf Configure Script Exception,
Packit Service 9646c7
# version 3.0, as published by the Free Software Foundation.
Packit Service 9646c7
#
Packit Service 9646c7
# You should have received a copy of the GNU General Public License
Packit Service 9646c7
# and a copy of the Autoconf Configure Script Exception along with
Packit Service 9646c7
# this program; see the files COPYINGv3 and COPYING.EXCEPTION
Packit Service 9646c7
# respectively.  If not, see <http://www.gnu.org/licenses/>.
Packit Service 9646c7
Packit Service 9646c7
Packit Service 9646c7
## ------------------------ ##
Packit Service 9646c7
## Erlang EUnit unit tests. ##
Packit Service 9646c7
## ------------------------ ##
Packit Service 9646c7
Packit Service 9646c7
# AT_CHECK_EUNIT(MODULE, SPEC, [ERLFLAGS], [RUN-IF-FAIL], [RUN-IF-PASS])
Packit Service 9646c7
# ----------------------------------------------------------------------
Packit Service 9646c7
# Check that the EUnit test specification SPEC passes. The ERLFLAGS
Packit Service 9646c7
# optional flags are passed to the Erlang interpreter command line to
Packit Service 9646c7
# execute the test. The test is executed from an automatically
Packit Service 9646c7
# generated Erlang module named MODULE. Each call to this macro should
Packit Service 9646c7
# have a distinct MODULE name within each test group, to ease
Packit Service 9646c7
# debugging.
Packit Service 9646c7
# An Erlang/OTP version which contains the eunit library must be
Packit Service 9646c7
# installed, in order to execute this macro in a test suite.  The ERL,
Packit Service 9646c7
# ERLC, and ERLCFLAGS variables must be defined in atconfig,
Packit Service 9646c7
# typically by using the AC_ERLANG_PATH_ERL and AC_ERLANG_PATH_ERLC
Packit Service 9646c7
# Autoconf macros.
Packit Service 9646c7
_AT_DEFINE_SETUP([AT_CHECK_EUNIT],
Packit Service 9646c7
[AT_SKIP_IF([test ! -f "$ERL" || test ! -f "$ERLC"])
Packit Service 9646c7
## A wrapper to EUnit, to exit the Erlang VM with the right exit code:
Packit Service 9646c7
AT_DATA([$1.erl],
Packit Service 9646c7
[[-module($1).
Packit Service 9646c7
-export([test/0, test/1]).
Packit Service 9646c7
test() -> test([]).
Packit Service 9646c7
test(Options) ->
Packit Service 9646c7
  TestSpec = $2,
Packit Service 9646c7
  ReturnValue = case code:load_file(eunit) of
Packit Service 9646c7
    {module, _} -> case eunit:test(TestSpec, Options) of
Packit Service 9646c7
        ok -> "0\n"; %% test passes
Packit Service 9646c7
        _  -> "1\n"  %% test fails
Packit Service 9646c7
      end;
Packit Service 9646c7
    _ -> "77\n" %% EUnit not found, test skipped
Packit Service 9646c7
  end,
Packit Service 9646c7
  file:write_file("$1.result", ReturnValue),
Packit Service 9646c7
  init:stop().
Packit Service 9646c7
]])
Packit Service 9646c7
AT_CHECK(["$ERLC" $ERLCFLAGS -b beam $1.erl])
Packit Service 9646c7
## Make EUnit verbose when testsuite is verbose:
Packit Service 9646c7
if test -z "$at_verbose"; then
Packit Service 9646c7
  at_eunit_options="verbose"
Packit Service 9646c7
else
Packit Service 9646c7
  at_eunit_options=""
Packit Service 9646c7
fi
Packit Service 9646c7
AT_CHECK(["$ERL" $3 -s $1 test $at_eunit_options -noshell], [0], [ignore], [],
Packit Service 9646c7
         [$4], [$5])
Packit Service 9646c7
AT_CAPTURE_FILE([$1.result])
Packit Service 9646c7
AT_CHECK([test -f "$1.result" && (exit `cat "$1.result"`)])
Packit Service 9646c7
])