# Copyright (c) 2010 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: ShellUtilConf.pm,v 2.3 2011/12/06 02:54:29 nagler Exp $ package Bivio::Test::ShellUtilConf; use strict; use Bivio::Base 'TestUnit.ShellUtil'; our($VERSION) = sprintf('%d.%02d', q$Revision: 2.3 $ =~ /\d+/g); my($_FP) = b_use('Type.FilePath'); my($_F) = b_use('IO.File'); sub generate_cases { my($self) = @_; return [map( $_ =~ m{/(\d+)\.in$} ? ($1 => 0) : (), glob( $_FP->join( $self->builtin_bunit_base_name, '*', ), ), )]; } sub new_unit { my($self) = shift->SUPER::new_unit(@_); $self->builtin_options({ compute_params => sub { my(undef, $params) = @_; my($in) = $_F->absolute_path( $_FP->join( $self->builtin_bunit_base_name, "$params->[0].in", ), ); $self->builtin_go_dir( $_FP->join( $self->builtin_bunit_base_name, $params->[0], ), ); return [ '-input', $in, 'generate', ]; }, check_return => sub { my(undef, undef) = @_; my($n) = $_F->pwd =~ /(\d+)$/; my($d) = "$n-out"; $_F->do_in_dir( '..', sub { $_F->rm_rf($_F->absolute_path($d)); system("tar xzf $d.tgz") == 0 || die; return; }, ); my($diff) = scalar( Bivio::ShellUtil->do_backticks( qq{diff '--ignore-matching-lines=^#' -r '../$d' .})); $_F->chdir('../..'); return $diff ? [$diff] : []; }, }); return $self; } 1;