Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 42 lines (35 sloc) 1.277 kB
b80ab7c update clean-whitespace, add automated whitespace test, and clean whi…
Paul Lindner authored
1 #!/usr/bin/perl
2 use strict;
3 use FindBin qw($Bin);
4 our @files;
5
6 BEGIN {
7 chdir "$Bin/.." or die;
071cf9f @dustin New whitespace test.
dustin authored
8
41b5576 @dormando stupid whitespace thing pulls in dead files
dormando authored
9 my @exempted = qw(Makefile.am ChangeLog doc/Makefile.am README README.md);
743fab4 @dustin Wider reaching whitespace cleanup.
dustin authored
10 push(@exempted, glob("doc/*.xml"));
11 push(@exempted, glob("doc/xml2rfc/*.xsl"));
a0a7032 @dustin Backporting AC_PROG_CC_C99 macro for redhat.
dustin authored
12 push(@exempted, glob("m4/*backport*m4"));
67c9060 @dormando whitespace fix for freebsd
dormando authored
13 push(@exempted, glob("*.orig"));
071cf9f @dustin New whitespace test.
dustin authored
14 my %exempted_hash = map { $_ => 1 } @exempted;
15
c9d03aa @dustin Use ls-files instead of ls-tree to run whitespace tests.
dustin authored
16 my @stuff = split /\0/, `git ls-files -z -c -m -o --exclude-standard`;
17 @files = grep { ! $exempted_hash{$_} } @stuff;
071cf9f @dustin New whitespace test.
dustin authored
18
19 # We won't find any files if git isn't installed. If git isn't
20 # installed, they're probably not doing any useful development, or
21 # at the very least am will clean up whitespace when we receive
22 # their patch.
23 unless (@files) {
24 use Test::More;
25 plan skip_all => "Skipping tests probably because you don't have git.";
26 exit 0;
27 }
b80ab7c update clean-whitespace, add automated whitespace test, and clean whi…
Paul Lindner authored
28 }
071cf9f @dustin New whitespace test.
dustin authored
29
b80ab7c update clean-whitespace, add automated whitespace test, and clean whi…
Paul Lindner authored
30 use Test::More tests => scalar(@files);
31
32 foreach my $f (@files) {
45f22f0 @dormando descriptive errors for t/whitespace.t
dormando authored
33 open(my $fh, $f) or die "Cannot open file $f: $!";
b80ab7c update clean-whitespace, add automated whitespace test, and clean whi…
Paul Lindner authored
34 my $before = do { local $/; <$fh>; };
35 close ($fh);
36 my $after = $before;
37 $after =~ s/\t/ /g;
38 $after =~ s/ +$//mg;
39 $after .= "\n" unless $after =~ /\n$/;
40 ok ($after eq $before, "$f (see devtools/clean-whitespace.pl)");
41 }
Something went wrong with that request. Please try again.