#!/usr/bin/perl # Wrapper for jenny, a pairwise test design tool # (http://burtleburtle.net/bob/math/jenny.html) # Reads an input file formatted for ALLPAIRS, runs jenny, and formats # the output like ALLPAIRS (missing some of the metrics) # (http://satisfice.com/testmethod.shtml) # Original author: Danny R. Faught (http://tejasconsulting.com/) # License: public domain # Version: 1.1 (2006-01-22) use warnings; use strict; my $file = shift or die "didn't specify filename\n"; open(IN, $file) or die "open $file: $!\n"; # # read the input file # my $header = ; $header =~ s/(\r|\n)*$//; my @header = split "\t", $header; my %values; my $line = 0; while () { $_ =~ s/(\r|\n)*$//; my $column = 0; foreach my $value (split "\t", $_) { $values{$header[$column]}->[$line] = $value unless $value eq ""; ++$column; } ++$line; } # # run jenny # my @args; foreach my $column (@header) { push (@args, scalar @{$values{$column}}); } my $jenny = `jenny @args @ARGV`; die "$@\n" if $@; # # convert the output # $jenny =~ s/^ *//gm; # remove leading space on each line $jenny =~ s/ /\t/g; # convert separators to tabs foreach my $colnum (0..$#header) { foreach my $valnum (0..$#{$values{$header[$colnum]}}) { my $jenny_name = ($colnum + 1) . (chr(ord("a") + $valnum)); my $allpairs_name = $values{$header[$colnum]}->[$valnum]; $jenny =~ s/$jenny_name/$allpairs_name/g; } } # print, adding the test case number column to the front print "case\t", join("\t", @header), "\n"; my $case = 1; print join("\n", map({$_ = $case++ . "\t" . $_} split(/\n/, $jenny))), "\n";