make/tests/scripts/features/errors
Paul Smith fa937343f5 Clean up errors for invalid commands and add regression tests.
* src/function.c (func_shell_base): Use error() instead of recreating
the error output.
* src/job.c (exec_command): Show more standard error messages.
* src/load.c (unload_file): Fix whitespace in the error message.
* tests/scripts/features/errors: Add tests for starting non-
existent commands and new error message formats.
* tests/scripts/features/output-sync: New error message formats.
* tests/scripts/functions/shell: Ditto.
2018-08-04 12:37:19 -04:00

74 lines
1.5 KiB
Perl

# -*-perl-*-
$description = "Test ignored failures in recipe command lines";
run_make_test(qq!
one:
\t-exit 1
\texit 0
two:
\texit 1
\texit 0
!,
"one", "exit 1\n#MAKE#: [#MAKEFILE#;3: one] Error 1 (ignored)\nexit 0\n");
# TEST #1
# -------
run_make_test(undef, " -i two",
"exit 1\n#MAKE#: [#MAKEFILE#;6: two] Error 1 (ignored)\nexit 0\n");
# TEST #2
# -------
# Test that error line offset works
run_make_test(qq!
all:
\t\@echo hi
\t\@echo there
\t\@exit 1
!,
'', "hi\nthere\n#MAKE#: *** [#MAKEFILE#;5: all] Error 1", 512);
# TEST #3
# -------
# Try failing due to unknown command
my $unk = './foobarbazbozblat';
unlink($unk);
my $err = $ERR_no_such_file;
run_make_test(qq!
one: ; -$unk xx yy
two: ; $unk aa bb
!,
'one', "$unk xx yy\n#MAKE#: $unk: $err\n#MAKE#: [#MAKEFILE#;2: one] Error 127 (ignored)\n");
# TEST #4
# -------
run_make_test(undef, 'two -i',
"$unk aa bb\n#MAKE#: $unk: $err\n#MAKE#: [#MAKEFILE#;3: two] Error 127 (ignored)\n");
# TEST #5
# -------
run_make_test(undef, 'two',
"$unk aa bb\n#MAKE#: $unk: $err\n#MAKE#: *** [#MAKEFILE#;3: two] Error 127\n", 512);
# Try failing due to non-executable file
my $noexe = './barfooblatboz';
touch($noexe);
run_make_test(qq!
one: ; -$noexe xx yy
two: ; $noexe aa bb
!,
'one', "$noexe xx yy\n#MAKE#: $noexe: Permission denied\n#MAKE#: [#MAKEFILE#;2: one] Error 127 (ignored)\n");
unlink($noexe);
1;