File: cpp_comments.t

package info (click to toggle)
libdbd-sqlite3-perl 1.76-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,004 kB
  • sloc: ansic: 167,715; perl: 1,788; pascal: 277; makefile: 9
file content (40 lines) | stat: -rw-r--r-- 879 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/perl

use strict;
BEGIN {
	$|  = 1;
	$^W = 1;
}

use Test::More;

my @c_files = (<*.c>, <*.h>, <*.xs>);
plan tests => scalar(@c_files);

FILE:
foreach my $file (@c_files) {
    if ($file =~ /ppport.h/) {
        pass("$file is not ours to be tested");
        next;
    }

    open my $fh, '<', $file or die "$file: $!";
    my $line = 0;
    while (<$fh>) {
        $line++;
        if (/^(.*)\/\//) {
            my $m = $1;
            if ($m !~ /\*/ && $m !~ /(?:file|http|ftp):$/ && $m !~ m!"/*?$!) { # skip the // in c++ comment in parse.c
                fail("C++ comment in $file line $line: $m");
                next FILE;
            }
        }

        if (/#define\s+DBD_SQLITE_CROAK_DEBUG/) {
            fail("debug macro is enabled in $file line $line");
            next FILE;
        }
    }
    pass("$file has no C++ comments");
    close $fh;
}