make/tests/scripts/features/vpath
Paul Smith 971b02d58e tests: Run each file in a separate directory
Avoid cross-contamination between test files by creating a new
working directory for each file, and setting it as the current
directory before starting the tests in that file.

Rename the test output as tNNN.{base,log,diff,mk} where NNN is
a test number starting with 001 for the first test.  It is
slightly more annoying to find diff files since you can't use
autocomplete directly but it is simpler to match things.

Detect the source directory as the location of the test_driver.pl
script, so remove the separate -srcdir option.

* Makefile.am: Remove hacks to create symlinks when building
out-of-tree, and remove -srcdir option from run_make_tests.
* tests/test_driver.pl: Locate $srcpath based on __FILE__, then
compute $toppath as its parent.  Set $scriptpath under $srcpath
and $workpath under the current directory.  Toss $*_filename
and modify get_logfile() etc. to use the suffix directly.  Add
a chdir() around the invocation of the test.
* tests/run_make_tests.pl: Throw out the -srcdir option and use
$srcpath set in test_driver.pl.  The #WORK# helper is no longer
useful so remove it.  Set #PWD# to the current working dir. Always
search the local directory and $srcpath for config-flags.pm.
Use $srcpath for finding the thelp.pl script.
* tests/scripts/features/vpath: Don't put things in work/ as it
is no longer a subdirectory.
* tests/scripts/features/vpathgpath: Ditto.
* tests/scripts/features/vpathplus: Ditto.
* tests/scripts/misc/general1: Ditto.
* tests/scripts/misc/general2: Ditto.
* tests/scripts/options/dash-k: Ditto.
* tests/scripts/options/symlinks: Use $testpath as the working
directory.
* tests/scripts/variables/GNUMAKEFLAGS: Use the test helper to
display env var values (grepping for GNUMAKEFLAGS finds extra things
now that it is our current working directory).
2023-04-02 17:32:09 -04:00

116 lines
2.8 KiB
Perl

# -*-perl-*-
$description = "Test vpath for particular classes of filenames.";
$details = "";
mkdir('work');
@files_to_touch = ("work${pathsep}main.c","work${pathsep}defs.h",
"work${pathsep}kbd.c","work${pathsep}command.h",
"work${pathsep}commands.c","work${pathsep}display.c",
"work${pathsep}buffer.h","work${pathsep}insert.c",
"work${pathsep}command.c");
&touch(@files_to_touch);
run_make_test(q!
vpath %.c foo
vpath %.c work
vpath %.h work
objects = main.o kbd.o commands.o display.o insert.o
edit: $(objects) ; @echo cc -o $@ $^
main.o : main.c defs.h ; @echo cc -c $(firstword $^)
kbd.o : kbd.c defs.h command.h ; @echo cc -c kbd.c
commands.o : command.c defs.h command.h ; @echo cc -c commands.c
display.o : display.c defs.h buffer.h ; @echo cc -c display.c
insert.o : insert.c defs.h buffer.h ; @echo cc -c insert.c
!,
'', "cc -c work${pathsep}main.c\ncc -c kbd.c\ncc -c commands.c\n"
."cc -c display.c\ncc -c insert.c\n"
."cc -o edit main.o kbd.o commands.o display.o insert.o\n");
unlink(@files_to_touch);
# TEST 2: after vpath lookup ensure we don't get incorrect circular dependency
# warnings due to change of struct file ptr. Savannah bug #13529.
mkdir('vpath-d', 0777);
run_make_test(q!
vpath %.te vpath-d/
.SECONDARY:
default: vpath-d/a vpath-d/b
vpath-d/a: fail.te
vpath-d/b : fail.te
vpath-d/fail.te:
!,
'', "#MAKE#: Nothing to be done for 'default'.\n");
rmdir('vpath-d');
# Test VPATH vs vpath
run_make_test(q!
VPATH = work:#PWD#
vpath %.c foo
vpath %.c work
vpath %.c #PWD#
vpath %.h work
vpath %.c
vpath
all: ; @echo ALL IS WELL
!,
'', "ALL IS WELL\n");
# Test interaction of -lfoo and vpath
my @dirs_to_make = qw(a1 b1 a2 b2 b3);
for my $d (@dirs_to_make) {
mkdir($d, 0777);
}
my @files_to_touch = ("a1${pathsep}lib1.a",
"a1${pathsep}libc.a",
"b1${pathsep}lib1.so",
"a2${pathsep}lib2.a",
"b2${pathsep}lib2.so",
"lib3.a",
"b3${pathsep}lib3.so");
&touch(@files_to_touch);
my $answer = "a1${pathsep}lib1.a a1${pathsep}libc.a " .
"a2${pathsep}lib2.a lib3.a\n";
if ($port_type eq 'VMS-DCL') {
$answer =~ s/ /,/g;
}
run_make_test('
vpath %.h b3
vpath %.a a1
vpath %.so b1
vpath % a2 b2
vpath % b3
all: -l1 -lc -l2 -l3; @echo $^
',
'', $answer);
unlink(@files_to_touch);
for my $d (@dirs_to_make) {
rmdir($d);
}
# Check that if we find find files with VPATH, we don't do pattern search
mkdir("vpa");
run_make_test(q!
VPATH = vpa
%.x: ; @echo pattern $@
vpa/foo.x: ; @echo vpath $@
!,
'foo.x', "vpath vpa/foo.x\n");
rmdir("vpa");
1;