1 1.1 christos # -*-perl-*- 2 1.1 christos 3 1.1 christos $description = "Test the -L option."; 4 1.1 christos 5 1.1 christos $details = "Verify that symlink handling with and without -L works properly."; 6 1.1 christos 7 1.1 christos # Only run these tests if the system sypports symlinks 8 1.1 christos 9 1.1 christos # Apparently the Windows port of Perl reports that it does support symlinks 10 1.1 christos # (in that the symlink() function doesn't fail) but it really doesn't, so 11 1.1 christos # check for it explicitly. 12 1.1 christos 13 1.1 christos if ($port_type eq 'W32' || !( eval { symlink("",""); 1 })) { 14 1.1 christos # This test is N/A 15 1.1 christos -1; 16 1.1 christos } else { 17 1.1 christos 18 1.1 christos # Set up a symlink sym -> dep 19 1.1 christos # We'll make both dep and targ older than sym 20 1.1 christos $pwd =~ m%/([^/]+)$%; 21 1.1 christos $dirnm = $1; 22 1.1 christos &utouch(-10, 'dep'); 23 1.1 christos &utouch(-5, 'targ'); 24 1.1 christos symlink("../$dirnm/dep", 'sym'); 25 1.1 christos 26 1.1 christos # Without -L, nothing should happen 27 1.1 christos # With -L, it should update targ 28 1.1 christos run_make_test('targ: sym ; @echo make $@ from $<', '', 29 1.1 christos "#MAKE#: `targ' is up to date."); 30 1.1 christos run_make_test(undef, '-L', "make targ from sym"); 31 1.1 christos 32 1.1 christos # Now update dep; in all cases targ should be out of date. 33 1.1 christos &touch('dep'); 34 1.1 christos run_make_test(undef, '', "make targ from sym"); 35 1.1 christos run_make_test(undef, '-L', "make targ from sym"); 36 1.1 christos 37 1.1 christos # Now update targ; in all cases targ should be up to date. 38 1.1 christos &touch('targ'); 39 1.1 christos run_make_test(undef, '', "#MAKE#: `targ' is up to date."); 40 1.1 christos run_make_test(undef, '-L', "#MAKE#: `targ' is up to date."); 41 1.1 christos 42 1.1 christos # Add in a new link between sym and dep. Be sure it's newer than targ. 43 1.1 christos sleep(1); 44 1.1 christos rename('dep', 'dep1'); 45 1.1 christos symlink('dep1', 'dep'); 46 1.1 christos 47 1.1 christos # Without -L, nothing should happen 48 1.1 christos # With -L, it should update targ 49 1.1 christos run_make_test(undef, '', "#MAKE#: `targ' is up to date."); 50 1.1 christos run_make_test(undef, '-L', "make targ from sym"); 51 1.1 christos 52 1.1 christos rmfiles('targ', 'dep', 'sym', 'dep1'); 53 1.1 christos 54 1.1 christos # Check handling when symlinks point to non-existent files. Without -L we 55 1.1 christos # should get an error: with -L we should use the timestamp of the symlink. 56 1.1 christos 57 1.1 christos symlink("../$dirname/dep", 'sym'); 58 1.1 christos run_make_test('targ: sym ; @echo make $@ from $<', '', 59 1.1 christos "#MAKE#: *** No rule to make target `sym', needed by `targ'. Stop.", 512); 60 1.1 christos 61 1.1 christos run_make_test('targ: sym ; @echo make $@ from $<', '-L', 62 1.1 christos 'make targ from sym'); 63 1.1 christos 64 1.1 christos 65 1.1 christos rmfiles('targ', 'sym'); 66 1.1 christos 67 1.1 christos 1; 68 1.1 christos } 69