summaryrefslogtreecommitdiffstats
path: root/perl_checker.src/test/read_t.pm
blob: d7d9b9c2f48e0b17e3d39a5eaaff24d3b5e2bba1 (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
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) : ($_, '');
	    push @lines, $line;
	    push @logs, $log;
	}
	$line_number++;
    }
    @tests;
}

1;