summaryrefslogtreecommitdiffstats
path: root/perl_checker.src/test/read_t.pm
blob: a07c0416b40f8bee1cd94645c43809afff2e81e6 (plain)
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
package read_t;

use lib '../..';
use MDK::Common;

sub read_t {
    my ($file) = @_;

    my @tests;
    my ($column_width, $line_number, @lines, @logs);
    foreach (cat_($file), "\n") {
	if (/^$/) {
	    push @tests, { line_number => $line_number, lines => [ @lines ], logs => [ @logs ] } if @lines;
	    @lines = @logs = ();
	} else {
	    $column_width ||= length(first(/(.{20}\s+)/));
	    my ($line, $log) = $column_width > 25 && /(.{$column_width})(.*)/ ? (chomp_($1) . "\n", $2) : ($_, '');
	    $line =~ s/[ \t]*$//;
	    push @lines, $line;
	    push @logs, $log;
	}
	$line_number++;
    }
    @tests;
}

1;