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