xref: /openbsd/gnu/usr.bin/perl/t/porting/checkcase.t (revision d415bd75)
1#!/usr/bin/perl
2# Finds the files that have the same name, case insensitively in the build tree
3
4BEGIN {
5    @INC = '..' if -f '../TestInit.pm';
6    require './test.pl';
7}
8use TestInit qw(T); # T is chdir to the top level
9
10use warnings;
11use strict;
12use File::Find;
13
14my %files;
15my $test_count = 0;
16
17# in a parallel 'make test', temporary files and directories can
18# randomly appear and disappear; don't complain about these
19no warnings 'File::Find';
20
21find({no_chdir => 1, wanted => sub {
22	   my $name = $File::Find::name;
23	   # Assumes that the path separator is exactly one character.
24	   $name =~ s/^\..//;
25
26	   # Special exemption for Makefile, makefile
27	   return if $name =~ m!\A[Mm]akefile\z!;
28
29	   if ($name eq '.git') {
30	       # Don't scan the .git directory, as its contents are outside
31	       # our control. In particular, as fetch doesn't default to
32	       # --prune, # someone pushing a branch upstream with a name
33	       # which case-conflicts with a previously deleted branch will
34	       # cause action-at-a-distance failures, because locally
35	       # .git/logs/refs/remotes will contain both.
36	       ++$File::Find::prune;
37	       return;
38	   }
39
40	   push @{$files{lc $name}}, $name;
41	 }}, '.');
42
43foreach (sort values %files) {
44    is( @$_, 1, join(", ", @$_) ) or
45        do{ note($_) foreach @$_; };
46}
47
48done_testing();
49