Home | History | Annotate | Line # | Download | only in features
      1  1.1  christos #                                                                    -*-perl-*-
      2  1.1  christos 
      3  1.1  christos $description = "The following tests the -i option and the '-' in front of \n"
      4  1.1  christos               ."commands to test that make ignores errors in these commands\n"
      5  1.1  christos               ."and continues processing.";
      6  1.1  christos 
      7  1.1  christos $details = "This test runs two makes.  The first runs on a target with a \n"
      8  1.1  christos           ."command that has a '-' in front of it (and a command that is \n"
      9  1.1  christos           ."intended to fail) and then a delete command after that is \n"
     10  1.1  christos           ."intended to succeed.  If make ignores the failure of the first\n"
     11  1.1  christos           ."command as it is supposed to, then the second command should \n"
     12  1.1  christos           ."delete a file and this is what we check for.  The second make\n"
     13  1.1  christos           ."that is run in this test is identical except that the make \n"
     14  1.1  christos           ."command is given with the -i option instead of the '-' in \n"
     15  1.1  christos           ."front of the command.  They should run the same. ";
     16  1.1  christos 
     17  1.1  christos if ($vos)
     18  1.1  christos {
     19  1.1  christos    $rm_command = "delete_file";
     20  1.1  christos }
     21  1.1  christos else
     22  1.1  christos {
     23  1.1  christos    $rm_command = "rm";
     24  1.1  christos }
     25  1.1  christos 
     26  1.1  christos open(MAKEFILE,"> $makefile");
     27  1.1  christos 
     28  1.1  christos # The Contents of the MAKEFILE ...
     29  1.1  christos 
     30  1.1  christos print MAKEFILE "clean:\n"
     31  1.1  christos               ."\t-$rm_command cleanit\n"
     32  1.1  christos               ."\t$rm_command foo\n"
     33  1.1  christos 	      ."clean2: \n"
     34  1.1  christos               ."\t$rm_command cleanit\n"
     35  1.1  christos               ."\t$rm_command foo\n";
     36  1.1  christos 
     37  1.1  christos # END of Contents of MAKEFILE
     38  1.1  christos 
     39  1.1  christos close(MAKEFILE);
     40  1.1  christos 
     41  1.1  christos &touch("foo");
     42  1.1  christos 
     43  1.1  christos unlink("cleanit");
     44  1.1  christos $cleanit_error = `sh -c "$rm_command cleanit 2>&1"`;
     45  1.1  christos $delete_error_code = $? >> 8;
     46  1.1  christos 
     47  1.1  christos # TEST #1
     48  1.1  christos # -------
     49  1.1  christos 
     50  1.1  christos $answer = "$rm_command cleanit\n"
     51  1.1  christos          . $cleanit_error
     52  1.1  christos          ."$make_name: [clean] Error $delete_error_code (ignored)\n"
     53  1.1  christos          ."$rm_command foo\n";
     54  1.1  christos 
     55  1.1  christos &run_make_with_options($makefile,"",&get_logfile);
     56  1.1  christos 
     57  1.1  christos # If make acted as planned, it should ignore the error from the first
     58  1.1  christos # command in the target and execute the second which deletes the file "foo"
     59  1.1  christos # This file, therefore, should not exist if the test PASSES.
     60  1.1  christos if (-f "foo") {
     61  1.1  christos   $test_passed = 0;
     62  1.1  christos }
     63  1.1  christos 
     64  1.1  christos # The output for this on VOS is too hard to replicate, so we only check it
     65  1.1  christos # on unix.
     66  1.1  christos if (!$vos)
     67  1.1  christos {
     68  1.1  christos    &compare_output($answer,&get_logfile(1));
     69  1.1  christos }
     70  1.1  christos 
     71  1.1  christos 
     72  1.1  christos &touch("foo");
     73  1.1  christos 
     74  1.1  christos # TEST #2
     75  1.1  christos # -------
     76  1.1  christos 
     77  1.1  christos $answer = "$rm_command cleanit\n"
     78  1.1  christos          . $cleanit_error
     79  1.1  christos          ."$make_name: [clean2] Error $delete_error_code (ignored)\n"
     80  1.1  christos          ."$rm_command foo\n";
     81  1.1  christos 
     82  1.1  christos &run_make_with_options($makefile,"clean2 -i",&get_logfile);
     83  1.1  christos 
     84  1.1  christos if (-f "foo") {
     85  1.1  christos   $test_passed = 0;
     86  1.1  christos }
     87  1.1  christos 
     88  1.1  christos if (!$vos) {
     89  1.1  christos    &compare_output($answer,&get_logfile(1));
     90  1.1  christos }
     91  1.1  christos 
     92  1.1  christos 1;
     93