Debian Codegraph @

tests/scripts/options/symlinks

raw
1 # -*-perl-*-
2
3 $description = "Test the -L option.";
4
5 $details = "Verify that symlink handling with and without -L works properly.";
6
7 # Only run these tests if the system sypports symlinks
8
9 exists $FEATURES{'check-symlink'} or return -1;
10
11 use File::Spec;
12
13 # Set up a symlink sym -> dep
14 # We'll make both dep and targ older than sym
15 &utouch(-10, 'dep');
16 &utouch(-5, 'targ');
17
18 $dirnm = (File::Spec->splitdir($cwddir))[-1];
19 symlink(File::Spec->catfile(File::Spec->updir(), $dirnm, 'dep'), 'sym');
20
21 # Without -L, nothing should happen
22 # With -L, it should update targ
23 run_make_test('targ: sym ; @echo make $@ from $<', '',
24 "#MAKE#: 'targ' is up to date.");
25 run_make_test(undef, '-L', "make targ from sym");
26
27 # Now update dep; in all cases targ should be out of date.
28 &touch('dep');
29 run_make_test(undef, '', "make targ from sym");
30 run_make_test(undef, '-L', "make targ from sym");
31
32 # Now update targ; in all cases targ should be up to date.
33 &touch('targ');
34 run_make_test(undef, '', "#MAKE#: 'targ' is up to date.");
35 run_make_test(undef, '-L', "#MAKE#: 'targ' is up to date.");
36
37 # Add in a new link between sym and dep. Be sure it's newer than targ.
38 sleep(1);
39 rename('dep', 'dep1');
40 symlink('dep1', 'dep');
41
42 # Without -L, nothing should happen
43 # With -L, it should update targ
44 run_make_test(undef, '', "#MAKE#: 'targ' is up to date.");
45 run_make_test(undef, '-L', "make targ from sym");
46
47 rmfiles('targ', 'dep', 'sym', 'dep1');
48
49 # Check handling when symlinks point to non-existent files. Without -L we
50 # should get an error: with -L we should use the timestamp of the symlink.
51
52 symlink("../$dirnm/dep", 'sym');
53 run_make_test('targ: sym ; @echo make $@ from $<', '',
54 "#MAKE#: *** No rule to make target 'sym', needed by 'targ'. Stop.", 512);
55
56 run_make_test('targ: sym ; @echo make $@ from $<', '-L',
57 'make targ from sym');
58
59
60 rmfiles('targ', 'sym');
61
62 1;