Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 58640fb9

Von Sven Schöling vor fast 14 Jahren hinzugefügt

  • ID 58640fb9e668911ee9625eae9923e1795f1b8082
  • Vorgänger 3443355d
  • Nachfolger d60e7dee

Experimentelles Linkchecker Testscript

Unterschiede anzeigen:

t/007broken_links.t
1
#!/usr/bin/perl
2

  
3
use strict;
4
use File::Find;
5
use LWP::Simple;
6
use Test::More tests => 1;
7
use URI::Find;
8

  
9
my @fails;
10

  
11
my $finder = URI::Find->new(sub {
12
  my ($uri_obj, $uri_text) = @_;
13
  $uri_text =~ s/^\<//;
14
  $uri_text =~ s/\>$//;
15

  
16
  push @fails, "$uri_text in file $File::Find::name"
17
    if !defined get($uri_text);
18

  
19
  return $_[1];
20
});
21

  
22
find(sub {
23
  open(FH, $File::Find::name) or return;
24
  my $text;
25
  { local $/; $text = <FH>; }
26

  
27
  $finder->find(\$text);
28

  
29
  }, "."
30
);
31

  
32
if (@fails) {
33
  ok(0, join "\n", @fails);
34
} else {
35
  ok(1, "no broken links found");
36
}

Auch abrufbar als: Unified diff