Skip to content

Commit

Permalink
Add save-temps=DIR test
Browse files Browse the repository at this point in the history
  • Loading branch information
lefessan committed Nov 29, 2023
1 parent ebc4024 commit 4ef509b
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 4 deletions.
7 changes: 3 additions & 4 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,8 @@ clean_up_intermediates (struct filename *fn, const int status)
if (fn->need_preprocess
&& (status
|| cb_compile_level > CB_LEVEL_PREPROCESS
|| (cb_compile_level == CB_LEVEL_PREPROCESS && save_temps))) {
|| (cb_compile_level == CB_LEVEL_PREPROCESS
&& save_temps && !save_temps_dir))) {
cobc_check_action (fn->preprocess);
}
/* CHECKME: we had reports of unexpected intermediate
Expand Down Expand Up @@ -2289,9 +2290,7 @@ cobc_clean_up (const int status)
|| cb_compile_level > CB_LEVEL_ASSEMBLE
|| (cb_compile_level == CB_LEVEL_ASSEMBLE
&& save_temps
/* do not move object if a name was
* specified on the command line */
&& !output_name))) {
&& !save_temps_dir))) {
cobc_check_action (fn->object);
}
clean_up_intermediates (fn, status);
Expand Down
89 changes: 89 additions & 0 deletions tests/testsuite.src/used_binaries.at
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,95 @@ AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [OK], [])
AT_CLEANUP


AT_SETUP([save-temps in sub-directory])
AT_KEYWORDS([runmisc])

AT_DATA([prog.cob], [
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
PROCEDURE DIVISION.
DISPLAY "OK" NO ADVANCING
END-DISPLAY.
EXIT PROGRAM.
])

AT_CHECK([mkdir debug])

AT_CHECK([$COMPILE -save-temps=debug -o prog.exe prog.cob])

AT_CHECK([$COBCRUN_DIRECT ./prog.exe], [0], [OK])

AT_CHECK([test -f debug/prog.$COB_OBJECT_EXT])

AT_CHECK([test -f debug/prog.c])

AT_CHECK([test -f debug/prog.s], [1])

AT_CHECK([test -f debug/prog.i])

AT_CHECK([test -f debug/prog.c.h])

AT_CHECK([test -f debug/prog.c.l.h])

# Check with -c

AT_CHECK([test -f prog.$COB_OBJECT_EXT], [1])

AT_CHECK([$COMPILE -save-temps=debug -c prog.cob])

AT_CHECK([test -f prog.$COB_OBJECT_EXT])

AT_CHECK([$COMPILE -save-temps=debug -c -o program.$COB_OBJECT_EXT prog.cob])

AT_CHECK([test -f program.$COB_OBJECT_EXT])

# Check with -S

AT_CHECK([test -f prog.s], [1])

AT_CHECK([$COMPILE -save-temps=debug -S prog.cob])

AT_CHECK([test -f prog.s])

AT_CHECK([$COMPILE -save-temps=debug -S -o program.s prog.cob])

AT_CHECK([test -f program.s])

# Check with -C

AT_CHECK([test -f prog.c], [1])

AT_CHECK([$COMPILE -save-temps=debug -C prog.cob])

AT_CHECK([test -f prog.c])

AT_CHECK([test -f prog.c.h])

AT_CHECK([test -f prog.c.l.h])

AT_CHECK([$COMPILE -save-temps=debug -C -o program.c prog.cob])

AT_CHECK([test -f program.c])

AT_CHECK([test -f program.c.h])

AT_CHECK([test -f program.c.l.h])

# Check with -E

AT_CHECK([test -f prog.i], [1])

AT_CHECK([$COMPILE -save-temps=debug -E -o prog.i prog.cob])

AT_CHECK([test -f prog.i])

AT_CHECK([$COMPILE -save-temps=debug -E -o program.i prog.cob])

AT_CHECK([test -f program.i])

AT_CLEANUP


AT_SETUP([C Compiler optimizations])
AT_KEYWORDS([runmisc cobc optimization])

Expand Down

0 comments on commit 4ef509b

Please sign in to comment.