| 1 | # -*- CPerl -*- | ||||||||||||||||||||
| 2 | # | ||||||||||||||||||||
| 3 | # Copyright (c) 2003,2004,2005 Alexander Taler (dissent@0--0.org) | ||||||||||||||||||||
| 4 | # | ||||||||||||||||||||
| 5 | # All rights reserved. This program is free software; you can redistribute it | ||||||||||||||||||||
| 6 | # and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||
| 7 | # | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | ######################### | ||||||||||||||||||||
| 10 | # Test lcvs-st | ||||||||||||||||||||
| 11 | ######################### | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | # This script should be in a directory called t and should be run from the | ||||||||||||||||||||
| 14 | # parent directory of that. It will test the lcvs-st in its parent directory. | ||||||||||||||||||||
| 15 | # It looks for various things under that assumption. | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | # The test creates a repository and sandboxes, which is fairly time intensive. | ||||||||||||||||||||
| 18 | # If you want to save this time, set LCVS_ST_T_TEST_REPO_DIR to a directory | ||||||||||||||||||||
| 19 | # name which you want to use. If the directory exists it will be reused. Be | ||||||||||||||||||||
| 20 | # careful if you change the directory, or upgrade the script, because this may | ||||||||||||||||||||
| 21 | # break the tests. It's also useful if tests are failing, and you want to | ||||||||||||||||||||
| 22 | # check out the contents of the repository to find out why, since it won't be | ||||||||||||||||||||
| 23 | # removed. | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | # Please excuse the shell scripty stuff here. | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 28 | 1 | ▶ | use Test; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 1 | ▶ | use File::Spec; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 31 | 1 | ▶ | use File::Temp qw/ tempdir /; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 1 | ▶ | BEGIN { plan tests => 111 } | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | # Find the directory where this script is. | ||||||||||||||||||||
| 36 | 1 | my ($vol, $dirname, $exename) = File::Spec->splitpath($0); | |||||||||||||||||||
| 37 | 1 | $dirname = File::Spec->rel2abs( $dirname ); | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | # set up the test repository | ||||||||||||||||||||
| 40 | my $base = ( $ENV{LCVS_ST_T_TEST_REPO_DIR} | ||||||||||||||||||||
| 41 | 1 | ▶ | || tempdir("libcvs-lcvs_st_t-XXXXXX", TMPDIR => 1, CLEANUP => 1)); | ||||||||||||||||||
|
Condition33%1/3
$ENV{'LCVS_ST_T_TEST_REPO_DIR'} || tempdir('libcvs-lcvs_st_t-XXXXXX', 'TMPDIR', 1, 'CLEANUP', 1)
MC/DC0%0/2
$ENV{'LCVS_ST_T_TEST_REPO_DIR'} || tempdir('libcvs-lcvs_st_t-XXXXXX', 'TMPDIR', 1, 'CLEANUP', 1)
$ENV{'LCVS_ST_T_TEST_REPO_DIR'}
tempdir('libcvs-lcvs_st_t-XXXXXX', 'TMPDIR', 1, 'CLEANUP', 1)
Truth table33%1/3
A || B
A= $ENV{'LCVS_ST_T_TEST_REPO_DIR'}B= tempdir('libcvs-lcvs_st_t-XXXXXX', 'TMPDIR', 1, 'CLEANUP', 1)
| |||||||||||||||||||||
| 42 | 1 | system("chmod +x $dirname/lcvs-st.t-setup.sh"); | |||||||||||||||||||
| 43 | 1 | ok(! system("$dirname/lcvs-st.t-setup.sh $base")); | |||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | # get the right lcvs-st and include path | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 1 | my $lcvs_st = "perl -I$dirname/../../blib/lib $dirname/../lcvs-st"; | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | # Check that the results are all there, and that the status is reported | ||||||||||||||||||||
| 50 | # correctly. Files are named the same as their expected results. | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | # All of the files that should be found by lcvs-st. They are named after their | ||||||||||||||||||||
| 53 | # status as it should be reported by lcvs-st. | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 1 | my @expected_files = ( "ABM", "ABU", "AUM", "AUU", | |||||||||||||||||||
| 56 | "NMM", "NMU", "NUM", | ||||||||||||||||||||
| 57 | "RMB", "RMM", "RMU", "RUB", "RUM", "RUU", | ||||||||||||||||||||
| 58 | "UBB", "UBM", "UBU", "UCB", "UCC", "UCM", "UCU", | ||||||||||||||||||||
| 59 | "UMB", "UMC", "UMM", "UMU", "UUB", "UUM", "UUU" ); | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | # First set of tests, just invoke it in the directory | ||||||||||||||||||||
| 62 | { | ||||||||||||||||||||
| 63 | 1 | my $results = `cd $base/sandbox1/dir1; $lcvs_st`; | |||||||||||||||||||
| 64 | 1 | my @result_lines = split (/\n/, $results); | |||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 1 | ▶ | ok(scalar @result_lines, scalar @expected_files) || exit 1; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 0 | foreach my $file (@expected_files) { | |||||||||||||||||||
| 69 | 0 | ok (shift (@result_lines), "$file $file"); | |||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | } | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | # Second set of tests, invoke it for each expected file | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 0 | foreach my $file (@expected_files) { | |||||||||||||||||||
| 76 | 0 | ok(`cd $base/sandbox1/dir1; $lcvs_st $file`, "$file $file\n"); | |||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | # Third set of tests, just invoke it in a subdirectory | ||||||||||||||||||||
| 80 | { | ||||||||||||||||||||
| 81 | 0 | my $results = `cd $base/sandbox1; $lcvs_st dir1`; | |||||||||||||||||||
| 82 | 0 | my @result_lines = split (/\n/, $results); | |||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | 0 | ▶ | ok(scalar @result_lines, scalar @expected_files) || exit 1; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 0 | foreach my $file (@expected_files) { | |||||||||||||||||||
| 87 | 0 | ok (shift (@result_lines), "$file dir1/$file"); | |||||||||||||||||||
| 88 | } | ||||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | # Fourth set of tests, invoke it in a subdirectory for each expected file | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 0 | foreach my $file (@expected_files) { | |||||||||||||||||||
| 94 | 0 | ok(`cd $base/sandbox1; $lcvs_st dir1/$file`, "$file dir1/$file\n"); | |||||||||||||||||||
| 95 | } | ||||||||||||||||||||