Rex

 view release on metacpan or  search on metacpan

lib/Rex/CLI.pm  view on Meta::CPAN

  }
}

sub handle_lock_file {
  my $rexfile = shift;

  if ( $OSNAME !~ m/^MSWin/ ) {
    if ( -f "$rexfile.lock" && !exists $opts{'F'} ) {
      Rex::Logger::debug("Found $rexfile.lock");
      my $pid = eval {
        local ( @ARGV, $INPUT_RECORD_SEPARATOR ) = ("$rexfile.lock");
        <>;
      };
      system(
        "ps aux | awk -F' ' ' { print \$2 } ' | grep $pid >/dev/null 2>&1");
      if ( $CHILD_ERROR == 0 ) {
        Rex::Logger::info("Rexfile is in use by $pid.");
        CORE::exit 1;
      }
      else {
        Rex::Logger::debug("Found stale lock file. Removing it.");

lib/Rex/CMDB/YAML.pm  view on Meta::CPAN

      if ( !exists $template_vars{$key} ) {
        $template_vars{$key} = $config_values->{$key};
      }
    }
    $template_vars{environment} = Rex::Commands::environment();

    for my $file (@files) {
      Rex::Logger::debug("CMDB - Opening $file");
      if ( -f $file ) {

        my $content = eval { local ( @ARGV, $/ ) = ($file); <>; };
        my $t       = Rex::Config->get_template_function();
        $content .= "\n"; # for safety
        $content = $t->( $content, \%template_vars );

        my $ref = YAML::Load($content);

        $result = $self->{merger}->merge( $result, $ref );
      }
    }
  }

lib/Rex/Commands/Box.pm  view on Meta::CPAN

 };

=cut

sub list_boxes {
  my $box = Rex::Box->create;
  my @ret = $box->list_boxes;

  my $ref = LOCAL {
    if ( -f ".box.cache" ) {
      my $yaml_str = eval { local ( @ARGV, $/ ) = (".box.cache"); <>; };
      $yaml_str .= "\n";
      my $yaml_ref = Load($yaml_str);

      for my $box ( keys %{$yaml_ref} ) {
        my ($found_box) = grep { $_->{name} eq $box } @ret;
        if ( !$found_box ) {
          $yaml_ref->{$box} = undef;
          delete $yaml_ref->{$box};
        }
      }

lib/Rex/Commands/Box.pm  view on Meta::CPAN

    $box->wait_for_ssh;
  }

  my $box_ip   = $box->ip;
  my $box_info = $box->info;

  return LOCAL {

    if ( -f ".box.cache" ) {
      Rex::Logger::debug("Loading box information of cache file: .box.cache.");
      my $yaml_str = eval { local ( @ARGV, $/ ) = (".box.cache"); <>; };
      $yaml_str .= "\n";
      my $yaml_ref = Load($yaml_str);
      %vm_infos = %{$yaml_ref};
    }

    if ( exists $vm_infos{$box_name} ) {
      return $vm_infos{$box_name};
    }

    my $pid = fork;

lib/Rex/Commands/Box.pm  view on Meta::CPAN

  return { get_system_information() };
}, { dont_register => 1, exit_on_connect_fail => 0 };

sub load_init_file {
  my ( $class, $file ) = @_;

  if ( !-f $file ) {
    die("Error: Wrong configuration file: $file.");
  }

  my $yaml_str = eval { local ( @ARGV, $/ ) = ($file); <>; };
  $yaml_str .= "\n";

  my $yaml_ref = Load($yaml_str);

  if ( !exists $yaml_ref->{type} ) {
    die("You have to define a type.");
  }

  my $type = ucfirst $yaml_ref->{type};
  set box_type => $type;

lib/Rex/Commands/File.pm  view on Meta::CPAN

    # $content = template("files/hosts.tpl");
    #
    # rex -E live ...
    # will first look if files/hosts.tpl.live is available, if not it will
    # use files/hosts.tpl
    if ( -f "$file." . Rex::Config->get_environment ) {
      $file = "$file." . Rex::Config->get_environment;
    }

    if ( -f $file ) {
      $content = eval { local ( @ARGV, $/ ) = ($file); <>; };
    }
    elsif ( $file =~ m/^\@/ ) {
      my @caller = caller(0);

      my $file_path = Rex::get_module_path( $caller[0] );

      if ( !-f $file_path ) {
        my ($mod_name) = ( $caller[0] =~ m/^.*::(.*?)$/ );
        if ( $mod_name && -f "$file_path/$mod_name.pm" ) {
          $file_path = "$file_path/$mod_name.pm";

lib/Rex/Commands/File.pm  view on Meta::CPAN

          $file_path = "$file_path/Module.pm";
        }
        elsif ( -f $caller[1] ) {
          $file_path = $caller[1];
        }
        elsif ( $caller[1] =~ m|^/loader/[^/]+/__Rexfile__.pm$| ) {
          $file_path = $INC{"__Rexfile__.pm"};
        }
      }

      my $file_content = eval { local ( @ARGV, $/ ) = ($file_path); <>; };
      my ($data)       = ( $file_content =~ m/.*__DATA__(.*)/ms );
      my $fp = Rex::File::Parser::Data->new( data => [ split( /\n/, $data ) ] );
      my $snippet_to_read = substr( $file, 1 );
      $content = $fp->read($snippet_to_read);
    }
    else {
      die("$file not found");
    }
  }

lib/Rex/Commands/Pkg.pm  view on Meta::CPAN

    my $need_md5  = ( $option->{"on_change"} ? 1 : 0 );
    my $on_change = $option->{"on_change"} || sub { };
    my $__ret;

    my ( $new_md5, $old_md5 ) = ( "", "" );

    if ( $source =~ m/\.tpl$/ ) {

      # das ist ein template

      my $content = eval { local ( @ARGV, $/ ) = ($source); <>; };

      my $vars          = $option->{"template"};
      my %merge1        = %{ $vars || {} };
      my %merge2        = Rex::Hardware->get(qw/ All /);
      my %template_vars = ( %merge1, %merge2 );

      if ($need_md5) {
        eval { $old_md5 = md5($package); };
      }

lib/Rex/Commands/Pkg.pm  view on Meta::CPAN

      $fh->close;

      if ($need_md5) {
        eval { $new_md5 = md5($package); };
      }

    }
    else {

      my $source  = Rex::Helper::Path::get_file_path( $source, caller() );
      my $content = eval { local ( @ARGV, $/ ) = ($source); <>; };

      my $local_md5 = "";
      if ( $option->{force} ) {
        upload $source, $package;
      }
      else {
        eval {
          $old_md5 = md5($package);
          chomp $old_md5;
        };

lib/Rex/Config.pm  view on Meta::CPAN

  if ( ref($HOME_CONFIG_YAML) && exists $HOME_CONFIG_YAML->{$topic} ) {
    &$code( $HOME_CONFIG_YAML->{$topic} );
  }
}

sub read_config_file {
  my ($config_file) = @_;
  $config_file ||= _home_dir() . "/.rex/config.yml";

  if ( -f $config_file ) {
    my $yaml = eval { local ( @ARGV, $/ ) = ($config_file); <>; };
    eval { $HOME_CONFIG_YAML = Load($yaml); };

    if ($@) {
      print STDERR "Error loading $config_file\n";
      print STDERR "$@\n";
      exit 2;
    }

    for my $key ( keys %{$HOME_CONFIG} ) {
      if ( exists $HOME_CONFIG_YAML->{$key} ) {

lib/Rex/Config.pm  view on Meta::CPAN

      }
    }
  }
}

sub read_ssh_config_file {
  my ($config_file) = @_;
  $config_file ||= _home_dir() . '/.ssh/config';

  if ( -f $config_file ) {
    my @lines = eval { local (@ARGV) = ($config_file); <>; };
    %SSH_CONFIG_FOR = _parse_ssh_config(@lines);
  }
}

sub _parse_ssh_config {
  my (@lines) = @_;

  my %ret = ();

  my ( @host, $in_host );

lib/Rex/Interface/Cache/YAML.pm  view on Meta::CPAN

  }

  my $file_name = "$path/" . Rex::Commands::connection->server . ".yml";

  if ( !-f $file_name ) {

    # no cache found
    return;
  }

  my $yaml = eval { local ( @ARGV, $/ ) = ($file_name); <>; };

  $yaml .= "\n";

  $self->{__data__} = YAML::Load($yaml);
}

1;

t/config-ssh.t  view on Meta::CPAN

Rex::Config::read_ssh_config_file( $tempdir . '/cfg2' );

is( $c->{'frontend2'}->{'user'},     '123' );
is( $c->{'frontend2'}->{'hostname'}, 'this.is.a.domain.tld' );
is( $c->{'frontend2'}->{'port'},     1005 );

is( $c->{'some'}->{'port'},  '3306' );
is( $c->{'other'}->{'port'}, '3306' );
is( $c->{'hosts'}->{'port'}, '3306' );

my @lines = eval { local (@ARGV) = ("t/ssh_config.1"); <>; };
my %data  = Rex::Config::_parse_ssh_config(@lines);

ok( exists $data{"*"}, "Host * exists" );
ok(
  exists $data{"*"}->{stricthostkeychecking},
  "Host * / StrictHostKeyChecking exists"
);
ok(
  $data{"*"}->{stricthostkeychecking} eq "no",
  "Host * / StrictHostKeyChecking and contains 'no'"

t/cron.t  view on Meta::CPAN


our $VERSION = '9999.99.99_99'; # VERSION

use Test::More;
use Test::Warnings;

$^O =~ m/^MSWin/ ? plan tests => 84 : plan tests => 287;

use Rex::Cron::Base;

my @lines = eval { local (@ARGV) = ("t/cron.ex"); <>; };
chomp @lines;

my $c = Rex::Cron::Base->new;
$c->parse_cron(@lines);
my @cron = $c->list;

is( $cron[0]->{type}, "comment", "first line is a comment" );

is( $cron[1]->{type}, "comment",                   "second line is comment" );
is( $cron[1]->{line}, "# Shell variable for cron", "got the line content #2" );

t/cron.t  view on Meta::CPAN

is( $cron[17]->{cron}->{command}, "false", "the 9th job / cmd" );
is( $cron[17]->{line}, "0 0 * * 0 false",  "the 9th job / cron line" );

unless ( $^O =~ m/^MSWin/ ) {
  #
  # Write new entries and test again
  #

  my $file = $c->write_cron();
  @lines = undef;
  @lines = eval { local (@ARGV) = ($file); <>; };
  chomp @lines;
  unlink $file;

  $c = Rex::Cron::Base->new;
  $c->parse_cron(@lines);
  @cron = $c->list;

  is( $cron[0]->{type}, "comment", "first line is a comment" );

  is( $cron[1]->{type}, "comment", "second line is comment" );

t/df.t  view on Meta::CPAN

use v5.12.5;
use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 37;
use Test::Warnings;

use Rex::Commands::Fs;

my @lines = eval { local (@ARGV) = ("t/df.out2"); <>; };

my $df = Rex::Commands::Fs::_parse_df(@lines);

ok( exists $df->{tmpfs}, "found tmpfs" );
is( $df->{tmpfs}->{used_perc},  '0%',       "tmpfs percent usage" );
is( $df->{tmpfs}->{free},       255160,     "tmpfs free" );
is( $df->{tmpfs}->{mounted_on}, "/dev/shm", "tmpfs mounted_on" );
is( $df->{tmpfs}->{used},       0,          "tmpfs used" );
is( $df->{tmpfs}->{size},       255160,     "tmpfs size" );

t/df.t  view on Meta::CPAN

ok( exists $df->{"/dev/sda2"}, "found /dev/sda2" );
is( $df->{"/dev/sda2"}->{used_perc},  '10%',    "/dev/sda2 percent usage" );
is( $df->{"/dev/sda2"}->{free},       15489344, "/dev/sda2 free" );
is( $df->{"/dev/sda2"}->{mounted_on}, "/",      "/dev/sda2 mounted_on" );
is( $df->{"/dev/sda2"}->{used},       1693244,  "/dev/sda2 used" );
is( $df->{"/dev/sda2"}->{size},       18102140, "/dev/sda2 size" );

@lines = ();
$df    = {};

@lines = eval { local (@ARGV) = ("t/df.out1"); <>; };

$df = Rex::Commands::Fs::_parse_df(@lines);

ok( exists $df->{tmpfs}, "found tmpfs" );
is( $df->{tmpfs}->{used_perc},  '0%',       "tmpfs percent usage" );
is( $df->{tmpfs}->{free},       255160,     "tmpfs free" );
is( $df->{tmpfs}->{mounted_on}, "/dev/shm", "tmpfs mounted_on" );
is( $df->{tmpfs}->{used},       0,          "tmpfs used" );
is( $df->{tmpfs}->{size},       255160,     "tmpfs size" );

t/dmi.t  view on Meta::CPAN

use v5.12.5;
use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 32;
use Test::Warnings;

use Rex::Inventory::DMIDecode;

my @lines = eval { local (@ARGV) = ("t/dmi.linux.out"); <>; };
my $dmi   = Rex::Inventory::DMIDecode->new( lines => \@lines );

isa_ok( $dmi, "Rex::Inventory::DMIDecode", "dmi object" );

my $bb      = $dmi->get_base_board;
my $bios    = $dmi->get_bios;
my @cpus    = $dmi->get_cpus;
my @mems    = $dmi->get_memory_modules;
my @mema    = $dmi->get_memory_arrays;
my $sysinfo = $dmi->get_system_information;

t/dmi.t  view on Meta::CPAN


@lines   = undef;
$dmi     = undef;
$bb      = undef;
$bios    = undef;
@cpus    = undef;
@mems    = undef;
@mema    = undef;
$sysinfo = undef;

@lines = eval { local (@ARGV) = ("t/dmi.obsd.out"); <>; };
$dmi   = Rex::Inventory::DMIDecode->new( lines => \@lines );

isa_ok( $dmi, "Rex::Inventory::DMIDecode", "dmi object (obsd)" );

$bb      = $dmi->get_base_board;
$bios    = $dmi->get_bios;
@cpus    = $dmi->get_cpus;
@mems    = $dmi->get_memory_modules;
@mema    = $dmi->get_memory_arrays;
$sysinfo = $dmi->get_system_information;

t/dmi.t  view on Meta::CPAN


@lines   = undef;
$dmi     = undef;
$bb      = undef;
$bios    = undef;
@cpus    = undef;
@mems    = undef;
@mema    = undef;
$sysinfo = undef;

@lines = eval { local (@ARGV) = ("t/dmi.fbsd.out"); <>; };
$dmi   = Rex::Inventory::DMIDecode->new( lines => \@lines );

isa_ok( $dmi, "Rex::Inventory::DMIDecode", "dmi object (fbsd)" );

$bb      = $dmi->get_base_board;
$bios    = $dmi->get_bios;
@cpus    = $dmi->get_cpus;
@mems    = $dmi->get_memory_modules;
@mema    = $dmi->get_memory_arrays;
$sysinfo = $dmi->get_system_information;

t/host.t  view on Meta::CPAN

use v5.12.5;
use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 11;
use Test::Warnings;

use Rex::Commands::Host;

my @content = eval { local (@ARGV) = ("t/hosts.ex"); <>; };
my @ret     = Rex::Commands::Host::_parse_hosts(@content);

is( $ret[0]->{host}, "localhost", "got localhost" );
is( $ret[0]->{ip},   "127.0.0.1", "got 127.0.0.1" );

@ret = get_host( "mango", @content );
is( $ret[0]->{ip},   "192.168.2.23",     "got 192.168.2.23 by alias" );
is( $ret[0]->{host}, "mango.rexify.org", "got mango.rexify.org by alias" );

@content = eval { local (@ARGV) = ("t/hosts.ex2"); <>; };
@ret     = Rex::Commands::Host::_parse_hosts(@content);

is( $ret[0]->{host}, "localhost",  "got localhost" );
is( $ret[0]->{ip},   "127.0.0.1",  "got 127.0.0.1" );
is( $ret[2]->{host}, "rexify.org", "got rexify.org" );
is( $ret[2]->{ip},   "1.2.3.4",    "got 1.2.3.4" );

@ret = get_host( "rexify.org", @content );
is( $ret[0]->{ip},   "1.2.3.4",    "got 1.2.3.4 from get_host" );
is( $ret[0]->{host}, "rexify.org", "got rexify.org from get_host" );

t/issue/948.t  view on Meta::CPAN

}

sub Rex::Commands::Fs::unlink {
  my ($file) = @_;
}

sub Rex::Helper::Run::i_run {
  my ($exec) = @_;

  if ( $exec =~ m/virsh.*capabilities/ ) {
    return eval { local (@ARGV) = ("t/issue/948/capabilities.xml"); <>; };
  }

  if ( $exec =~ m/^qemu\-img create/ ) {
    my $fmt = get_image_format();
    like $exec, qr/^qemu\-img create \-f $fmt/, "qemu-img created a raw image.";
    $count_exec++;
  }

  return "";
}

t/issue_539.t  view on Meta::CPAN

use v5.12.5;
use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 17;
use Test::Warnings;
use Rex::Hardware::Network::Linux;
use Rex::Helper::Hash;

my @in   = eval { local (@ARGV) = ("t/ip.out_issue_539"); <>; };
my $info = Rex::Hardware::Network::Linux::_parse_ip(@in);

is( $info->{eth0}->{broadcast}, "192.168.178.255", "eth0 primary / broadcast" );
is( $info->{eth0}->{ip},        "192.168.178.81",  "eth0 primary / ip" );
is( $info->{eth0}->{netmask},   "255.255.255.0",   "eth0 primary / netmask" );
is( $info->{eth0}->{mac},       "08:00:27:4b:b8:48", "eth0 primary / mac" );

is( $info->{eth0_1}->{broadcast},
  "192.168.99.255", "eth0 secondary / broadcast" );
is( $info->{eth0_1}->{ip},      "192.168.99.37", "eth0 secondary / ip" );

t/net_interface_centos7.t  view on Meta::CPAN


use v5.12.5;
use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 7;
use Test::Warnings;
use Rex::Hardware::Network::Linux;

my @in   = eval { local (@ARGV) = ("t/ip.out_centos7"); <>; };
my $info = Rex::Hardware::Network::Linux::_parse_ip(@in);

is( $info->{lo}->{netmask}, '255.0.0.0', 'loopback netmask' );
is( $info->{lo}->{ip},      '127.0.0.1', 'loopback ip' );

is( $info->{eth0}->{ip},        '10.211.55.171',     'eth0 ip' );
is( $info->{eth0}->{netmask},   '255.255.255.0',     'eth0 netmask' );
is( $info->{eth0}->{broadcast}, '10.211.55.255',     'eth0 broadcast' );
is( $info->{eth0}->{mac},       '00:1c:42:fe:5a:b5', 'eth0 mac' );

@in   = eval { local (@ARGV) = ("t/ip.out_centos7_alias"); <>; };
$info = Rex::Hardware::Network::Linux::_parse_ip(@in);

1;

t/network_linux.t  view on Meta::CPAN

use v5.12.5;
use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 45;
use Test::Warnings;
use Rex::Hardware::Network::Linux;
use Rex::Helper::Hash;

my @in   = eval { local (@ARGV) = ("t/ifconfig.out1"); <>; };
my $info = Rex::Hardware::Network::Linux::_parse_ifconfig(@in);

is( $info->{eth0}->{broadcast}, "10.18.1.255",       "ex1 / broadcast" );
is( $info->{eth0}->{ip},        "10.18.1.107",       "ex1 / ip" );
is( $info->{eth0}->{netmask},   "255.255.255.0",     "ex1 / netmask" );
is( $info->{eth0}->{mac},       "00:16:3e:7f:fc:3a", "ex1 / mac" );

my $f = {};
hash_flatten( $info, $f, "_" );
is( $f->{eth0_mac},       "00:16:3e:7f:fc:3a", "ex1 / flatten / mac" );
is( $f->{eth0_ip},        "10.18.1.107",       "ex1 / flatten / ip" );
is( $f->{eth0_netmask},   "255.255.255.0",     "ex1 / flatten / netmask" );
is( $f->{eth0_broadcast}, "10.18.1.255",       "ex1 / flatten / broadcast" );

@in   = eval { local (@ARGV) = ("t/ifconfig.out2"); <>; };
$info = Rex::Hardware::Network::Linux::_parse_ifconfig(@in);

ok( !$info->{"vif1.0"}->{broadcast}, "ex2 / broadcast" );
ok( !$info->{"vif1.0"}->{ip},        "ex2 / ip" );
ok( !$info->{"vif1.0"}->{netmask},   "ex2 / netmask" );
is( $info->{"vif1.0"}->{mac}, "fe:ff:ff:ff:ff:ff", "ex2 / mac" );

$f = {};
hash_flatten( $info, $f, "_" );
is( $f->{"vif1_0_mac"}, "fe:ff:ff:ff:ff:ff", "ex2 / flatten / mac" );
ok( !$f->{"vif1_0_ip"},        "ex2 / flatten / ip" );
ok( !$f->{"vif1_0_netmask"},   "ex2 / flatten / netmask" );
ok( !$f->{"vif1_0_broadcast"}, "ex2 / flatten / broadcast" );

@in   = eval { local (@ARGV) = ("t/ip.out1"); <>; };
$info = Rex::Hardware::Network::Linux::_parse_ip(@in);

is( $info->{wlp2s0}->{ip},        "10.20.30.40",       "ip / ip" );
is( $info->{wlp2s0}->{netmask},   "255.255.255.0",     "ip / netmask" );
is( $info->{wlp2s0}->{broadcast}, "10.20.30.255",      "ip / broadcast" );
is( $info->{wlp2s0}->{mac},       "aa:bb:cc:dd:ee:ff", "ip / mac" );

$f = {};
hash_flatten( $info, $f, "_" );
is( $f->{"wlp2s0_mac"},       "aa:bb:cc:dd:ee:ff", "ip / flatten / mac" );
is( $f->{"wlp2s0_ip"},        "10.20.30.40",       "ip / flatten / ip" );
is( $f->{"wlp2s0_netmask"},   "255.255.255.0",     "ip / flatten / netmask" );
is( $f->{"wlp2s0_broadcast"}, "10.20.30.255",      "ip / flatten / broadcast" );

$info = {};
@in   = eval { local (@ARGV) = ("t/ip.out2"); <>; };
$info = Rex::Hardware::Network::Linux::_parse_ip(@in);
is( $info->{eth1}->{ip},        "",                  "ip / ip" );
is( $info->{eth1}->{netmask},   "",                  "ip / netmask" );
is( $info->{eth1}->{broadcast}, "",                  "ip / broadcast" );
is( $info->{eth1}->{mac},       "00:1c:42:73:ad:3c", "ip / mac" );

@in   = eval { local (@ARGV) = ("t/ifconfig.out6"); <>; };
$info = Rex::Hardware::Network::Linux::_parse_ifconfig(@in);

is( $info->{eth0}->{broadcast}, "192.168.112.255", "(fc19) eth0 / broadcast" );
is( $info->{eth0}->{ip},        "192.168.112.182", "(fc19) eth0 / ip" );
is( $info->{eth0}->{netmask},   "255.255.255.0",   "(fc19) eth0 / netmask" );
is( $info->{eth0}->{mac},       "52:54:00:37:a8:e1", "(fc19) eth0 / mac" );

is( $info->{"eth0:1"}->{broadcast}, "1.2.255.255",
  "(fc19) eth0:1 / broadcast" );
is( $info->{"eth0:1"}->{ip},      "1.2.3.4",     "(fc19) eth0:1 / ip" );
is( $info->{"eth0:1"}->{netmask}, "255.255.0.0", "(fc19) eth0:1 / netmask" );
is( $info->{"eth0:1"}->{mac},     "52:54:00:37:a8:e1", "(fc19) eth0:1 / mac" );

@in   = eval { local (@ARGV) = ("t/ifconfig.out7"); <>; };
$info = Rex::Hardware::Network::Linux::_parse_ifconfig(@in);
is( $info->{ppp0}->{ip},        "123.117.251.17",  "ppp0 / ip" );
is( $info->{ppp0}->{netmask},   "255.255.255.255", "ppp0 / netmask" );
is( $info->{ppp0}->{broadcast}, "",                "ppp0 / broadcast" );
is( $info->{ppp0}->{mac},       "",                "ppp0 / mac" );

@in   = eval { local (@ARGV) = ("t/ip.out3"); <>; };
$info = Rex::Hardware::Network::Linux::_parse_ip(@in);
is( $info->{ppp0}->{ip},        "123.117.251.17",  "ppp0 / ip" );
is( $info->{ppp0}->{netmask},   "255.255.255.255", "ppp0 / netmask" );
is( $info->{ppp0}->{broadcast}, "",                "ppp0 / broadcast" );
is( $info->{ppp0}->{mac},       "",                "ppp0 / mac" );

t/report.t  view on Meta::CPAN

  "test",
  sub {
    file( "test_report.txt", content => "this is a test" );
  }
);

Rex::TaskList->create()->get_task("test")->run("<local>");

my @files = list_files("tmp/report/_local_");
my $content =
  eval { local ( @ARGV, $/ ) = ("tmp/report/_local_/$files[0]"); <>; };

my $ref = Load($content);

is( $ref->{'file[test_report.txt]'}->{changed}, 1, "a new file was created." );

$report_num += 1;

Rex::TaskList->create()->get_task("test")->run("<local>");
@files = sort { $a =~ s/\.yml//; $b =~ s/\.yml//; $a <=> $b }
  list_files("tmp/report/_local_/");
$content =
  eval { local ( @ARGV, $/ ) = ("tmp/report/_local_/$files[1].yml"); <>; };

$ref = Load($content);

is( $ref->{'file[test_report.txt]'}->{changed}, 0, "the file was not changed" );

unlink "test_report.txt";

if ( $^O =~ m/^MSWin/ ) {
  system("rd /Q /S tmp\\report");
}



( run in 0.735 second using v1.01-cache-2.11-cpan-49f99fa48dc )