Home | History | Annotate | Line # | Download | only in features
reinvoke revision 1.1
      1  1.1  christos #                                                              -*-mode: perl-*-
      2  1.1  christos 
      3  1.1  christos $description = "Test GNU make's auto-reinvocation feature.";
      4  1.1  christos 
      5  1.1  christos $details = "\
      6  1.1  christos If the makefile or one it includes can be rebuilt then it is, and make
      7  1.1  christos is reinvoked.  We create a rule to rebuild the makefile from a temp
      8  1.1  christos file, then touch the temp file to make it newer than the makefile.";
      9  1.1  christos 
     10  1.1  christos $omkfile = $makefile;
     11  1.1  christos 
     12  1.1  christos &utouch(-600, 'incl.mk');
     13  1.1  christos # For some reason if we don't do this then the test fails for systems
     14  1.1  christos # with sub-second timestamps, maybe + NFS?  Not sure.
     15  1.1  christos &utouch(-1, 'incl-1.mk');
     16  1.1  christos 
     17  1.1  christos run_make_test('
     18  1.1  christos all: ; @echo running rules.
     19  1.1  christos 
     20  1.1  christos #MAKEFILE# incl.mk: incl-1.mk
     21  1.1  christos 	@echo rebuilding $@
     22  1.1  christos 	@echo >> $@
     23  1.1  christos 
     24  1.1  christos include incl.mk',
     25  1.1  christos               '', "rebuilding incl.mk\nrunning rules.\n");
     26  1.1  christos 
     27  1.1  christos # Make sure updating the makefile itself also works
     28  1.1  christos 
     29  1.1  christos &utouch(-600, $omkfile);
     30  1.1  christos 
     31  1.1  christos run_make_test(undef, '', "rebuilding #MAKEFILE#\nrunning rules.\n");
     32  1.1  christos 
     33  1.1  christos &rmfiles('incl.mk', 'incl-1.mk');
     34  1.1  christos 
     35  1.1  christos 
     36  1.1  christos # In this test we create an included file that's out-of-date, but then
     37  1.1  christos # the rule doesn't update it.  Make shouldn't re-exec.
     38  1.1  christos 
     39  1.1  christos &utouch(-600, 'b','a');
     40  1.1  christos #&utouch(-10, 'a');
     41  1.1  christos &touch('c');
     42  1.1  christos 
     43  1.1  christos run_make_test('
     44  1.1  christos SHELL = /bin/sh
     45  1.1  christos 
     46  1.1  christos all: ; @echo hello
     47  1.1  christos 
     48  1.1  christos a : b ; echo >> $@
     49  1.1  christos 
     50  1.1  christos b : c ; [ -f $@ ] || echo >> $@
     51  1.1  christos 
     52  1.1  christos c: ; echo >> $@
     53  1.1  christos 
     54  1.1  christos include $(F)',
     55  1.1  christos               'F=a', "[ -f b ] || echo >> b\nhello\n");
     56  1.1  christos 
     57  1.1  christos # Now try with the file we're not updating being the actual file we're
     58  1.1  christos # including: this and the previous one test different parts of the code.
     59  1.1  christos 
     60  1.1  christos run_make_test(undef, "F=b", "[ -f b ] || echo >> b\nhello\n")
     61  1.1  christos 
     62  1.1  christos &rmfiles('a','b','c');
     63  1.1  christos 
     64  1.1  christos # This tells the test driver that the perl test script executed properly.
     65  1.1  christos 1;
     66