[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: new test failures
From: |
Jim Meyering |
Subject: |
Re: new test failures |
Date: |
Fri, 17 Feb 2012 10:49:33 +0100 |
Akim Demaille wrote:
> Le 17 févr. 2012 à 09:29, Akim Demaille a écrit :
>
>> Ah, bummer, both are using "input" as input file
>> name. I guess you ran it -j. Will fix this, thanks
>> a lot!
>
> Fixed and installed in the following patch. I'm quite
> ambivalent here: I want these directories to be novice
> readable, they are really meant to demonstrate grammars.
> That's why the "test suites" are so simple minded, and
> that is also why I do not want to clutter them with too
> much clutter such as portability issues and so forth.
>
> Yet, as a result, I have a large part of code duplication
> between both versions of "test" :(
>
> I think I won't be able to resist much longer, and will
> fuse them. I just need to have it really simple and
> straightforward to understand.
>
> From c3a2e0e6dd060143cbd2854b61e435552883a6b7 Mon Sep 17 00:00:00 2001
> From: Akim Demaille <address@hidden>
> Date: Fri, 17 Feb 2012 10:12:06 +0100
> Subject: [PATCH] examples: fix the test suites.
>
> * examples/calc++/test, examples/mfcalc/test (me): Be more
> meaningfull: include the example name.
> (prog): Factor.
> (run): Avoid printf, use echo.
> Add missing parens.
> (cleanup): New.
> Call it on trap.
> Remove the previous "rm" that did the cleanup.
> Move into a private directory to avoid concurrency issues.
> Reported by Jim Meyering.
> ---
> examples/calc++/test | 34 +++++++++++++++++++++++++---------
> examples/mfcalc/test | 38 +++++++++++++++++++++++++++-----------
> 2 files changed, 52 insertions(+), 20 deletions(-)
>
> diff --git a/examples/calc++/test b/examples/calc++/test
> index 0dfe368..7930dc2 100755
> --- a/examples/calc++/test
> +++ b/examples/calc++/test
> @@ -15,7 +15,8 @@
> # You should have received a copy of the GNU General Public License
> # along with this program. If not, see <http://www.gnu.org/licenses/>.
>
> -me=`basename $0`
> +me=`dirname $0`
> +me=`basename $me`
>
> # Number of the current test.
> number=1
> @@ -24,31 +25,47 @@ number=1
> exit=true
>
> # The exercised program.
> -prog=./examples/calc++/calc++
> +prog=../examples/$me/$me
> +
> +# cleanup
> +# -------
> +cleanup ()
> +{
> + local status=$?
> + if test -z "$DEBUG"; then
> + cd ..
> + rm -rf $$.dir
> + fi
> + exit $status
> +}
> +trap cleanup 0 1 2 13 15
> +mkdir $$.dir
> +cd $$.dir
That's better (I confirmed it fixes the failures), but introduces a race.
If it's interrupted or fails between the trap and a successful "cd",
it will fail to clean up, and might try to remove $$.dir from the parent.
How about recording cwd=$(pwd) before cleanup definition,
and then using cd "$cwd" instead of "cd .."?