Skip to content

Commit da5c185

Browse files
author
ddeclerck
committed
Testing and overriding the diff command
* configure.ac: testing working diff with the option to override by DIFF tests: * atlocal.in, atlocal_win, cobol85/Makefile.am, cobol85/Makefile.module.in, testsuite.src/*.at: use the new DIFF variable to invoke the diff command
1 parent 79c65d0 commit da5c185

File tree

13 files changed

+125
-93
lines changed

13 files changed

+125
-93
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11

2+
2025-05-13 David Declerck <[email protected]>
3+
4+
* configure.ac: testing working diff with the option to override by DIFF
5+
26
2025-03-27 Simon Sobisch <[email protected]>
37

48
* configure.ac: fix --without-iconv; use iconv includes, if necessary;

configure.ac

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,14 +620,25 @@ AC_PROG_LEX([noyywrap])
620620
AX_PROG_FLEX
621621
AX_PROG_BISON
622622

623+
AC_CACHE_CHECK([for diff], [ac_cv_path_DIFF],
624+
[AC_PATH_PROGS_FEATURE_CHECK([DIFF], [diff],
625+
[[echo "x" > fx1 ; echo "x" > fx2 ; echo "y" > fy
626+
"$ac_path_DIFF" fx1 fx2 >/dev/null ; res0=$?
627+
"$ac_path_DIFF" fx1 fy >/dev/null ; res1=$?
628+
rm -f fx1 fx2 fy
629+
test $res0 = 0 -a $res1 = 1 \
630+
&& ac_cv_path_DIFF="$ac_path_DIFF" ac_path_DIFF_found=:]],
631+
[AC_MSG_ERROR([could not find a working diff])])])
632+
AC_SUBST([DIFF], [$ac_cv_path_DIFF])
633+
623634
AC_ARG_VAR(DIFF_FLAGS, arguments passed to diff)
624635
AC_MSG_CHECKING([for diff arguments])
625636
case "$DIFF_FLAGS" in
626637
*--strip-trailing-cr*)
627638
AC_MSG_RESULT([specified as $DIFF_FLAGS])
628639
;;
629640
*)
630-
diff $DIFF_FLAGS --strip-trailing-cr --version 1>/dev/null 2>&1
641+
"$DIFF" $DIFF_FLAGS --strip-trailing-cr --version 1>/dev/null 2>&1
631642
if test $? -eq 0; then
632643
if test -z "$DIFF_FLAGS"; then
633644
DIFF_FLAGS="--strip-trailing-cr"

tests/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11

2+
2025-05-13 David Declerck <[email protected]>
3+
4+
* atlocal.in, atlocal_win, cobol85/Makefile.am,
5+
cobol85/Makefile.module.in, testsuite.src/*.at:
6+
use the new DIFF variable to invoke the diff command
7+
28
2025-03-16 Simon Sobisch <[email protected]>
39

410
* atlocal.in: adjusted to handle newer MSYS2's setting OSTYPE=cygwin

tests/atlocal.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ else
5353
ABS_COBCRUN="$(which cobcrun)"
5454
fi
5555

56+
# We need to define a diff function, because:
57+
# - we want autotest to use our custom diff command
58+
# - the DIFF variable might contain spaces
59+
diff() {
60+
command "@DIFF@" @DIFF_FLAGS@ "$@"
61+
}
62+
DIFF=diff
5663
AWK=@AWK@
5764
GREP=@GREP@
5865
SED=@SED@

tests/atlocal_win

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ LOCAL_ENV=""
4040
PATH="${COB_WIN_BUILDPATH}:${PATH}"
4141
export PATH
4242

43+
DIFF=diff
4344
AWK=awk
4445
GREP=grep
4546
SED=sed

tests/cobol85/Makefile.am

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Makefile gnucobol/tests/cobol85
33
#
4-
# Copyright (C) 2002-2012, 2015-2024 Free Software Foundation, Inc.
4+
# Copyright (C) 2002-2012, 2015-2025 Free Software Foundation, Inc.
55
# Written by Keisuke Nishida, Roger While, Simon Sobisch
66
#
77
# This file is part of GnuCOBOL.
@@ -59,6 +59,7 @@ COBC_FLAGS = -std=cobol85 -debug $(COBOL_FLAGS)
5959

6060
CURL_FLAGS =
6161
WGET_FLAGS = -t1 -T5
62+
DIFF = @DIFF@
6263
DIFF_FLAGS = @DIFF_FLAGS@
6364

6465
PRE_INST_ENV = "$(abs_top_builddir)/pre-inst-env"
@@ -163,7 +164,7 @@ diff:
163164
@echo "Comparing test results for each module"
164165
@retd=0; for m in $(MODULES); do \
165166
echo "diff $$m/report.txt..."; \
166-
diff $(DIFF_FLAGS) "$(srcdir)/$$m.txt" "$$m/report.txt"; \
167+
"$(DIFF)" $(DIFF_FLAGS) "$(srcdir)/$$m.txt" "$$m/report.txt"; \
167168
ret=$$? && if test $$ret -gt $$retd; then retd=$$ret; fi \
168169
done; \
169170
if test $$retd -gt 1; then exit $$retd; fi
@@ -175,7 +176,7 @@ diff-summary:
175176
$(MAKE) summary.log
176177
@echo "Comparing total test results..."
177178
@echo "diff $(SUMMARY)..."
178-
@diff $(DIFF_FLAGS) "$(srcdir)/$(SUMMARY)" "summary.log"
179+
@"$(DIFF)" $(DIFF_FLAGS) "$(srcdir)/$(SUMMARY)" "summary.log"
179180
@echo Done
180181

181182
newcob.val.Z:
@@ -246,6 +247,7 @@ $(MODULES_ALL): newcob.val EXEC85$(EXEEXT) $(srcdir)/EXEC85.conf.in Makefile.mod
246247
@(export CBL_LIST="`ls $@/*.CBL | cut -f2 -d/ | tr '\n' ' '`" && \
247248
$(SED) -e 's/##MODULE##/'"$@"'/' \
248249
-e 's|##COB85DIR##|'$(abs_srcdir)'|' \
250+
-e 's|##DIFF##|'"$(DIFF)"'|' \
249251
-e 's|##DIFF_FLAGS##|'"$(DIFF_FLAGS)"'|' \
250252
-e 's|##PERL##|'"$(PERL)"'|' \
251253
-e 's|##TESTS##|'"` echo $$CBL_LIST | $(SED) -e 's/\.CBL//g'`"'|' \

tests/cobol85/Makefile.module.in

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Makefile gnucobol/tests/cobol85/##MODULE##
33
#
4-
# Copyright (C) 2002-2012, 2015-2020, 2022-2023 Free Software Foundation, Inc.
4+
# Copyright (C) 2002-2012, 2015-2020, 2022-2023, 2025 Free Software Foundation, Inc.
55
# Written by Keisuke Nishida, Roger While, Simon Sobisch
66
#
77
# This file is part of GnuCOBOL.
@@ -23,6 +23,7 @@ TESTS = ##TESTS##
2323
TESTS_LOCAL = ##TESTS_LOCAL##
2424

2525
RM = rm -rf
26+
DIFF = ##DIFF##
2627
DIFF_FLAGS = ##DIFF_FLAGS##
2728

2829
PERL = ##PERL##
@@ -61,7 +62,7 @@ test-local:
6162
diff: report.txt
6263
@echo
6364
@echo "Comparing test results for module directory ##MODULE##"
64-
@diff $(DIFF_FLAGS) ##COB85DIR##/##MODULE##.txt report.txt || true
65+
@"$(DIFF)" $(DIFF_FLAGS) ##COB85DIR##/##MODULE##.txt report.txt || true
6566

6667
test-O:
6768
@. ../../atconfig && . ../../atlocal && $(MAKE) $@-local
@@ -93,7 +94,7 @@ $(TESTS):
9394
$(TESTS_LOCAL): libs-local
9495
@echo "Running single test `echo $@ | sed -e 's|-.*||g'`"
9596
@$(PERL) ##COB85DIR##/report.pl `echo $@ | sed -e 's|-.*||g'` 2>[email protected]
96-
@grep `echo $@ | sed -e 's|-.*||g'` ##COB85DIR##/##MODULE##.txt | diff - [email protected]
97+
@grep `echo $@ | sed -e 's|-.*||g'` ##COB85DIR##/##MODULE##.txt | "$(DIFF)" - [email protected]
9798
9899

99100
clean: clean-log clean-db clean-debug clean-bin

tests/testsuite.src/listings.at

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ AT_CHECK([$COMPILE_ONLY -t prog.lst -tlines=2 prog.cob], [0], [],
7777
])
7878

7979
AT_CHECK([$UNIFY_LISTING prog.lst prog.lis], [0], [], [])
80-
AT_CHECK([diff expected.lst prog.lis], [0], [], [])
80+
AT_CHECK([$DIFF expected.lst prog.lis], [0], [], [])
8181

8282
AT_CLEANUP
8383

@@ -1709,9 +1709,9 @@ SIZE TYPE LVL NAME PICTURE
17091709
# Check once with $COMPILE and once with $COMPILE_ONLY.
17101710
# This tests whether codegen affects the listing.
17111711
AT_CHECK([$COMPILE $LISTING_FLAGS -t prog.lst -ftsymbols prog.cob], [0], [], [])
1712-
AT_CHECK([diff prog20.lst prog.lst], [0], [], [])
1712+
AT_CHECK([$DIFF prog20.lst prog.lst], [0], [], [])
17131713
AT_CHECK([$COMPILE_LISTING -t prog2.lst -ftsymbols prog.cob], [0], [], [])
1714-
AT_CHECK([diff prog20.lst prog2.lst], [0], [], [])
1714+
AT_CHECK([$DIFF prog20.lst prog2.lst], [0], [], [])
17151715

17161716
AT_CHECK([rm -f prog.lst prog2.lst], [0], [], [])
17171717

@@ -1776,9 +1776,9 @@ SIZE TYPE LVL NAME PICTURE
17761776
# Check once with $COMPILE and once with $COMPILE_ONLY.
17771777
# This tests whether codegen affects the listing.
17781778
AT_CHECK([$COMPILE $LISTING_FLAGS -t prog.lst -ftsymbols progb.cob], [0], [], [])
1779-
AT_CHECK([diff prog20b.lst prog.lst], [0], [], [])
1779+
AT_CHECK([$DIFF prog20b.lst prog.lst], [0], [], [])
17801780
AT_CHECK([$COMPILE_LISTING -t prog2.lst -ftsymbols progb.cob], [0], [], [])
1781-
AT_CHECK([diff prog20b.lst prog2.lst], [0], [], [])
1781+
AT_CHECK([$DIFF prog20b.lst prog2.lst], [0], [], [])
17821782

17831783
AT_CHECK([rm -f prog.lst prog2.lst], [0], [], [])
17841784

@@ -1850,9 +1850,9 @@ progc.cob:13: error: syntax error, unexpected ., expecting DIVISION
18501850
# Check once with $COMPILE and once with $COMPILE_ONLY.
18511851
# This tests whether codegen affects the listing.
18521852
AT_CHECK([$COMPILE $LISTING_FLAGS -t prog.lst -ftsymbols progc.cob], [1], [], [ignore])
1853-
AT_CHECK([diff prog20c.lst prog.lst], [0], [], [])
1853+
AT_CHECK([$DIFF prog20c.lst prog.lst], [0], [], [])
18541854
AT_CHECK([$COMPILE_LISTING -t prog2.lst -ftsymbols progc.cob], [1], [], [ignore])
1855-
AT_CHECK([diff prog20c.lst prog2.lst], [0], [], [])
1855+
AT_CHECK([$DIFF prog20c.lst prog2.lst], [0], [], [])
18561856

18571857
AT_CLEANUP
18581858

@@ -2027,10 +2027,10 @@ prog-2.cob:16: warning: unreachable statement 'ACCEPT'
20272027
# This tests whether codegen affects the listing.
20282028

20292029
AT_CHECK([$COMPILE $LISTING_FLAGS -Wunreachable -t prog.lst -Xref -ftsymbols prog-1.cob prog-2.cob], [0], [], [ignore])
2030-
AT_CHECK([diff expected.lst prog.lst], [0], [], [])
2030+
AT_CHECK([$DIFF expected.lst prog.lst], [0], [], [])
20312031

20322032
AT_CHECK([$COMPILE_LISTING -Wunreachable -t prog.lst -Xref -ftsymbols prog-1.cob prog-2.cob], [0], [], [ignore])
2033-
AT_CHECK([diff expected.lst prog.lst], [0], [], [])
2033+
AT_CHECK([$DIFF expected.lst prog.lst], [0], [], [])
20342034

20352035
AT_CLEANUP
20362036

@@ -2307,12 +2307,12 @@ SIZE TYPE LVL NAME PICTURE
23072307

23082308
])
23092309

2310-
AT_CHECK([diff prog15-1.lst prog.lst], [0], [], [])
2310+
AT_CHECK([$DIFF prog15-1.lst prog.lst], [0], [], [])
23112311

23122312
# verify that the symbol listing is identical if full codegen was done
23132313
AT_CHECK([$COMPILE $LISTING_FLAGS -t prog2.lst -tlines=0 -fno-tsource -fno-tmessages -ftsymbols prog3.cob], [0], [], [])
23142314

2315-
AT_CHECK([diff prog15-1.lst prog2.lst], [0], [], [])
2315+
AT_CHECK([$DIFF prog15-1.lst prog2.lst], [0], [], [])
23162316

23172317
AT_CLEANUP
23182318

@@ -2478,7 +2478,7 @@ SIZE TYPE LVL NAME PICTURE
24782478
0 errors in compilation group
24792479
])
24802480

2481-
AT_CHECK([diff prog17-32.lst prog.lst], [0], [], [])
2481+
AT_CHECK([$DIFF prog17-32.lst prog.lst], [0], [], [])
24822482

24832483
,
24842484

@@ -2587,7 +2587,7 @@ SIZE TYPE LVL NAME PICTURE
25872587
0 errors in compilation group
25882588
])
25892589

2590-
AT_CHECK([diff prog17-64.lst prog.lst], [0], [], [])
2590+
AT_CHECK([$DIFF prog17-64.lst prog.lst], [0], [], [])
25912591

25922592
)
25932593

@@ -3666,7 +3666,7 @@ prog.cob:81: warning: uncommon parentheses
36663666
50 errors in compilation group
36673667
])
36683668

3669-
AT_CHECK([diff expected.lst prog.lst], [0])
3669+
AT_CHECK([$DIFF expected.lst prog.lst], [0])
36703670

36713671
AT_CLEANUP
36723672

tests/testsuite.src/run_extensions.at

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ AT_DATA([reference],
14551455
040310Howdy 1 2 3<> 01***Abcdefghij. 34545656702***Abcdefghij. 45656767803***Abcdefghij. 567678789<>
14561456
])
14571457

1458-
AT_CHECK([diff reference SEQODO], [0], [], [])
1458+
AT_CHECK([$DIFF reference SEQODO], [0], [], [])
14591459

14601460
AT_CLEANUP
14611461

0 commit comments

Comments
 (0)