Skip to content

Commit

Permalink
Fix 'gap --version' to send its output to stdout
Browse files Browse the repository at this point in the history
Also add a trailing newline.
  • Loading branch information
fingolfin committed Jan 17, 2025
1 parent 8e778b5 commit eeba5ab
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
18 changes: 18 additions & 0 deletions dev/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,24 @@ GAPInput
testexpect)
INPUTRC=/tmp/inputrc expect -c "spawn $GAP -A -b $(gap_cover_arg 1)" $SRCDIR/dev/gaptest.expect
INPUTRC=/tmp/inputrc expect -c "spawn $GAP -A -b $(gap_cover_arg 2) -l missing-dir" $SRCDIR/dev/gaptest2.expect

# not using expect but in a similar vein: check `gap --version output`
echo "Testing 'gap --version'"
$GAP --version 0>gap_stdin 1>gap_stdout 2>gap_stderr
if [ -s gap_stdin ] ; then
echo "Error, 'gap --version' prints to stdin but should not"
exit 1
fi
if [ -s gap_stderr ] ; then
echo "Error, 'gap --version' prints to stderr but should not"
exit 1
fi
if ! fgrep -q 'GAP 4.' gap_stdout; then
# must look like "GAP 4.X.y ..."
echo "Error, 'gap --version' does not print expected output to stdout"
exit 1
fi

;;

*)
Expand Down
3 changes: 2 additions & 1 deletion src/gasman.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
#endif

#ifdef GAP_MEM_CHECK
#include <stdio.h>
#include <sys/mman.h>
#endif

Expand Down Expand Up @@ -1140,7 +1141,7 @@ Int EnableMemCheck = 0;

Int enableMemCheck(Char ** argv, void * dummy)
{
SyFputs( "# Warning: --enableMemCheck causes SEVERE slowdowns. Starting GAP may take several days!\n", 3 );
fputs("# Warning: --enableMemCheck causes SEVERE slowdowns. Starting GAP may take several days!\n", stderr);
EnableMemCheck = 1;
return 1;
}
Expand Down
13 changes: 7 additions & 6 deletions src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,19 +465,20 @@ static Int setGapRootPath( Char **argv, void *Dummy)

static Int enableMemCheck(Char ** argv, void * dummy)
{
SyFputs( "# Error: --enableMemCheck not supported by this copy of GAP\n", 3);
SyFputs( " pass --enable-memory-checking to ./configure\n", 3 );
fputs("# Error: --enableMemCheck not supported by this copy of GAP\n", stderr);
fputs(" pass --enable-memory-checking to ./configure\n", stderr);
SyExit(2);
}
#endif


static Int printVersion(Char ** argv, void * dummy)
{
SyFputs("GAP ", 1);
SyFputs(SyBuildVersion, 1);
SyFputs(" built on ", 1);
SyFputs(SyBuildDateTime, 1);
fputs("GAP ", stdout);
fputs(SyBuildVersion, stdout);
fputs(" built on ", stdout);
fputs(SyBuildDateTime, stdout);
fputs("\n", stdout);
SyExit(0);
}

Expand Down

0 comments on commit eeba5ab

Please sign in to comment.