- Enhance .POSIX to set -e when invoking shells, as demanded by a
[make.git] / tests / scripts / features / errors
blobe372fe05eee0fa1e8eaa6754a7c31f5d4b4d5562
1 #                                                                    -*-perl-*-
3 $description = "The following tests the -i option and the '-' in front of \n"
4               ."commands to test that make ignores errors in these commands\n"
5               ."and continues processing.";
7 $details = "This test runs two makes.  The first runs on a target with a \n"
8           ."command that has a '-' in front of it (and a command that is \n"
9           ."intended to fail) and then a delete command after that is \n"
10           ."intended to succeed.  If make ignores the failure of the first\n"
11           ."command as it is supposed to, then the second command should \n"
12           ."delete a file and this is what we check for.  The second make\n"
13           ."that is run in this test is identical except that the make \n"
14           ."command is given with the -i option instead of the '-' in \n"
15           ."front of the command.  They should run the same. ";
17 if ($vos)
19    $rm_command = "delete_file";
21 else
23    $rm_command = "rm";
26 open(MAKEFILE,"> $makefile");
28 # The Contents of the MAKEFILE ...
30 print MAKEFILE "clean:\n"
31               ."\t-$rm_command cleanit\n"
32               ."\t$rm_command foo\n"
33               ."clean2: \n"
34               ."\t$rm_command cleanit\n"
35               ."\t$rm_command foo\n";
37 # END of Contents of MAKEFILE
39 close(MAKEFILE);
41 &touch("foo");
43 unlink("cleanit");
44 $cleanit_error = `sh -c "$rm_command cleanit 2>&1"`;
45 $delete_error_code = $? >> 8;
47 # TEST #1
48 # -------
50 $answer = "$rm_command cleanit\n"
51          . $cleanit_error
52          ."$make_name: [clean] Error $delete_error_code (ignored)\n"
53          ."$rm_command foo\n";
55 &run_make_with_options($makefile,"",&get_logfile);
57 # If make acted as planned, it should ignore the error from the first
58 # command in the target and execute the second which deletes the file "foo"
59 # This file, therefore, should not exist if the test PASSES.
60 if (-f "foo") {
61   $test_passed = 0;
64 # The output for this on VOS is too hard to replicate, so we only check it
65 # on unix.
66 if (!$vos)
68    &compare_output($answer,&get_logfile(1));
72 &touch("foo");
74 # TEST #2
75 # -------
77 $answer = "$rm_command cleanit\n"
78          . $cleanit_error
79          ."$make_name: [clean2] Error $delete_error_code (ignored)\n"
80          ."$rm_command foo\n";
82 &run_make_with_options($makefile,"clean2 -i",&get_logfile);
84 if (-f "foo") {
85   $test_passed = 0;
88 if (!$vos) {
89    &compare_output($answer,&get_logfile(1));