On Wednesday 19 August 2009 15:59:01 Paolo Bonzini wrote:
> On 08/19/2009 03:56 AM, Romain Lenglet wrote:
> > The solution I have is to write the return result into a temp file
> > (conftest.out), and call init:stop() with no arg to cleanly flush the
> > standard output and exit with code 0.
>
> Makes sense, please send a patch.

Here is that patch.
I have tested only with Erlang/OTP R13B, but it should also work with R12B.

--
Romain Lenglet
From 5622ad4c2876cf95ee8ae23dd4b17e11c1cd48e1 Mon Sep 17 00:00:00 2001
From: Romain Lenglet <[email protected]>
Date: Wed, 19 Aug 2009 21:32:27 +0900
Subject: [PATCH] Fix AT_CHECK_EUNIT macro for version of Erlang/OTP which don't have function init:stop/1.

* lib/autotest/specific.m4 (AT_CHECK_EUNIT): Support older
versions of Erlang/OTP which erlang:stop() function doesn't take
arguments.
---
 ChangeLog                |    6 ++++++
 lib/autotest/specific.m4 |   11 +++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1242ca6..404fa0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-08-19  Romain Lenglet  <[email protected]>
+
+	* lib/autotest/specific.m4 (AT_CHECK_EUNIT): Support older
+	versions of Erlang/OTP which erlang:stop() function doesn't take
+	arguments.
+
 2009-08-18  Bruno Haible  <[email protected]>
 
 	Document Solaris tr range and NUL limitations.
diff --git a/lib/autotest/specific.m4 b/lib/autotest/specific.m4
index df32cfe..e1a21c8 100644
--- a/lib/autotest/specific.m4
+++ b/lib/autotest/specific.m4
@@ -74,12 +74,13 @@ test(Options) ->
   TestSpec = $2,
   ReturnValue = case code:load_file(eunit) of
     {module, _} -> case eunit:test(TestSpec, Options) of
-        ok -> 0; %% test passes
-        _  -> 1  %% test fails
+        ok -> "0\n"; %% test passes
+        _  -> "1\n"  %% test fails
       end;
-    _ -> 77 %% EUnit not found, test skipped
+    _ -> "77\n" %% EUnit not found, test skipped
   end,
-  init:stop(ReturnValue).
+  file:write_file("$1.result", ReturnValue),
+  init:stop().
 ]])
 AT_CHECK(["$ERLC" $ERLCFLAGS -b beam $1.erl])
 ## Make EUnit verbose when testsuite is verbose:
@@ -90,4 +91,6 @@ else
 fi
 AT_CHECK(["$ERL" $3 -s $1 test $at_eunit_options -noshell], [0], [ignore], [],
          [$4], [$5])
+AT_CAPTURE_FILE([$1.result])
+AT_CHECK([test -f "$1.result" && (exit `cat "$1.result"`)])
 ])
-- 
1.6.3.3

Reply via email to