summaryrefslogtreecommitdiff
path: root/tests/scripts
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2002-09-10 07:27:28 +0000
committerPaul Smith <psmith@gnu.org>2002-09-10 07:27:28 +0000
commit7ea029a07c02b9401cb3d88566eac41959b84c11 (patch)
tree0a26e865bee26f79c718258415b5389023076942 /tests/scripts
parent9b41488ad15e4ffc63b8094379c17f567b094c1b (diff)
downloadgunmake-7ea029a07c02b9401cb3d88566eac41959b84c11.tar.gz
Add support for broken SA_RESTART on PTX.
Fix bug #103: allow ifdef, export, and unexport to expand their arguments.
Diffstat (limited to 'tests/scripts')
-rw-r--r--tests/scripts/features/conditionals34
-rw-r--r--tests/scripts/features/export173
2 files changed, 207 insertions, 0 deletions
diff --git a/tests/scripts/features/conditionals b/tests/scripts/features/conditionals
index 3557fb5..ab3d9d5 100644
--- a/tests/scripts/features/conditionals
+++ b/tests/scripts/features/conditionals
@@ -63,5 +63,39 @@ arg4 is defined
&compare_output($answer,&get_logfile(1));
+
+# Test expansion of variables inside ifdef.
+
+$makefile2 = &get_tmpfile;
+
+open(MAKEFILE, "> $makefile2");
+
+print MAKEFILE <<'EOF';
+
+foo = 1
+
+FOO = foo
+F = f
+
+DEF = no
+DEF2 = no
+
+ifdef $(FOO)
+DEF = yes
+endif
+
+ifdef $(F)oo
+DEF2 = yes
+endif
+
+all:; @echo DEF=$(DEF) DEF2=$(DEF2)
+
+EOF
+
+&run_make_with_options($makefile2,"",&get_logfile,0);
+$answer = "DEF=yes DEF2=yes\n";
+&compare_output($answer,&get_logfile(1));
+
+
# This tells the test driver that the perl test script executed properly.
1;
diff --git a/tests/scripts/features/export b/tests/scripts/features/export
new file mode 100644
index 0000000..09aeac2
--- /dev/null
+++ b/tests/scripts/features/export
@@ -0,0 +1,173 @@
+# -*-perl-*-
+$description = "Check GNU make export/unexport commands.";
+
+$details = "";
+
+# The test driver cleans out our environment for us so we don't have to worry
+# about that here.
+
+open(MAKEFILE,"> $makefile");
+
+# The Contents of the MAKEFILE ...
+
+print MAKEFILE <<'EOMAKE';
+
+FOO = foo
+BAR = bar
+BOZ = boz
+
+export BAZ = baz
+export BOZ
+
+BITZ = bitz
+BOTZ = botz
+
+export BITZ BOTZ
+unexport BOTZ
+
+
+ifdef EXPORT_ALL
+export
+endif
+
+ifdef UNEXPORT_ALL
+unexport
+endif
+
+ifdef EXPORT_ALL_PSEUDO
+.EXPORT_ALL_VARIABLES:
+endif
+
+all:
+ @echo "FOO=$(FOO) BAR=$(BAR) BAZ=$(BAZ) BOZ=$(BOZ) BITZ=$(BITZ) BOTZ=$(BOTZ)"
+ @echo "FOO=$$FOO BAR=$$BAR BAZ=$$BAZ BOZ=$$BOZ BITZ=$$BITZ BOTZ=$$BOTZ"
+
+EOMAKE
+
+close(MAKEFILE);
+
+# TEST 0: basics
+
+&run_make_with_options($makefile,"",&get_logfile,0);
+
+$answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
+FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
+
+&compare_output($answer,&get_logfile(1));
+
+# TEST 1: make sure vars inherited from the parent are exported
+
+$ENV{FOO} = 1;
+
+&run_make_with_options($makefile,"",&get_logfile,0);
+
+$answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
+FOO=foo BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
+
+&compare_output($answer,&get_logfile(1));
+
+delete $ENV{FOO};
+
+# TEST 2: global export. Explicit unexport takes precedence.
+
+&run_make_with_options($makefile,"EXPORT_ALL=1",&get_logfile,0);
+
+$answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
+FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
+
+&compare_output($answer,&get_logfile(1));
+
+# TEST 3: global unexport. Explicit export takes precedence.
+
+&run_make_with_options($makefile,"UNEXPORT_ALL=1",&get_logfile,0);
+
+$answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
+FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
+
+&compare_output($answer,&get_logfile(1));
+
+# TEST 4: both: in the above makefile the unexport comes last so that rules.
+
+&run_make_with_options($makefile,"EXPORT_ALL=1 UNEXPORT_ALL=1",&get_logfile,0);
+
+$answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
+FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
+
+&compare_output($answer,&get_logfile(1));
+
+# TEST 5: test the pseudo target.
+
+&run_make_with_options($makefile,"EXPORT_ALL_PSEUDO=1",&get_logfile,0);
+
+$answer = "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
+FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
+
+&compare_output($answer,&get_logfile(1));
+
+
+# TEST 6: Test the expansion of variables inside export
+
+$makefile2 = &get_tmpfile;
+
+open(MAKEFILE, "> $makefile2");
+
+print MAKEFILE <<'EOF';
+
+foo = f-ok
+bar = b-ok
+
+FOO = foo
+F = f
+
+BAR = bar
+B = b
+
+export $(FOO)
+export $(B)ar
+
+all:
+ @echo foo=$(foo) bar=$(bar)
+ @echo foo=$$foo bar=$$bar
+
+EOF
+
+&run_make_with_options($makefile2,"",&get_logfile,0);
+$answer = "foo=f-ok bar=b-ok\nfoo=f-ok bar=b-ok\n";
+&compare_output($answer,&get_logfile(1));
+
+
+# TEST 7: Test the expansion of variables inside unexport
+
+$makefile3 = &get_tmpfile;
+
+open(MAKEFILE, "> $makefile3");
+
+print MAKEFILE <<'EOF';
+
+foo = f-ok
+bar = b-ok
+
+FOO = foo
+F = f
+
+BAR = bar
+B = b
+
+export foo bar
+
+unexport $(FOO)
+unexport $(B)ar
+
+all:
+ @echo foo=$(foo) bar=$(bar)
+ @echo foo=$$foo bar=$$bar
+
+EOF
+
+&run_make_with_options($makefile3,"",&get_logfile,0);
+$answer = "foo=f-ok bar=b-ok\nfoo= bar=\n";
+&compare_output($answer,&get_logfile(1));
+
+
+# This tells the test driver that the perl test script executed properly.
+1;