specific.m4 3.0 KB

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