summaryrefslogtreecommitdiff
path: root/tests/scripts/options/print-directory
blob: 7ba9a2e7493e9d95c94d36f0d5b2573bbe6425d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#                                                                    -*-perl-*-

$description = "Test the -w option to GNU make.";

my $enter = "#MAKE#: Entering directory '#PWD#'";
my $leave = "#MAKE#: Leaving directory '#PWD#'";

# Simple test without -w
run_make_test(q!
all: ; @echo hi
!,
        "", "hi\n");

my $ans = "$enter\nhi\n$leave\n";

# Simple test with -w
run_make_test(undef, "-w", $ans);

# Simple test with overriding -w
run_make_test(undef, "-w --no-print-directory", "hi\n");

# Simple test with overriding --no-print-directory
run_make_test(undef, "--no-print-directory --print-directory", $ans);

# Test makefile rebuild to ensure no enter/leave
run_make_test(q!
include foo
all: ;@:
foo: ; touch foo
!,
        "", "touch foo\n");
unlink('foo');

$ans = "$enter\ntouch foo\n$leave\n";

# Test makefile rebuild with -w
run_make_test(undef, "-w", $ans);
unlink('foo');

# Test makefile rebuild with -w overridden
run_make_test(undef, "-w --no-print-directory", "touch foo\n");
unlink('foo');

# Test makefile rebuild with --no-print-directory overridden
run_make_test(undef, "--no-print-directory --print-directory", $ans);
unlink('foo');

my $enter1 = "#MAKE#[1]: Entering directory '#PWD#'";
my $leave1 = "#MAKE#[1]: Leaving directory '#PWD#'";

$ans = "$enter1\nhi\n$leave1\n";

# Test makefile recursion with default enter/leave
run_make_test(q!
all: ;@$(MAKE) -f #MAKEFILE# recurse
recurse: ; @echo hi
!,
        "", $ans);

# Disable enter/leave
run_make_test(undef, "--no-print-directory", "hi\n");

# Re-enable enter/leave
$ans = "$enter\n$ans$leave\n";
run_make_test(undef, "--no-print-directory -w", $ans);

# Override enter/leave
run_make_test(undef, "-w --no-print-directory", "hi\n");

1;