Alien-Build

 view release on metacpan or  search on metacpan

t/alien_build_plugin_probe_commandline.t  view on Meta::CPAN

    });

    is(cap { $build->probe }, 'share');
    is $run, 0, 'run';
    is $lib, 1, 'lib';

  };

};

subtest 'match + version' => sub {

  my $guard = system_fake
    'foo' => sub { print "Froodle Foomaker version 1.00\n"; return 0 },
  ;

  subtest 'match good' => sub {
    my($build) = build(command => 'foo', match => qr/Froodle/);
    is cap { $build->probe }, 'system';
  };

  subtest 'match bad' => sub {
    my($build) = build(command => 'foo', match => qr/Droodle/);
    is cap { $build->probe }, 'share';
  };

  subtest 'version found' => sub {
    my($build) = build(command => 'foo', version => qr/version ([0-9\.]+)/);
    is cap { $build->probe }, 'system';
    is $build->runtime_prop->{version}, '1.00';
  };

  subtest 'version unfound' => sub {
    my($build) = build(command => 'foo', version => qr/version = ([0-9\.]+)/);
    is cap { $build->probe }, 'system';
    is $build->runtime_prop->{version}, undef;
  };

  subtest 'atleast_version satisfied' => sub {
    my($build) = build(
      command => 'foo',
      version => qr/version ([0-9\.]+)/,
      atleast_version => '0.5.0'
    );
    is cap { $build->probe }, 'system';
    is $build->runtime_prop->{version}, '1.00';
  };

  subtest 'atleast_version not satisfied' => sub {
    my($build) = build(
      command => 'foo',
      version => qr/version ([0-9\.]+)/,
      atleast_version => '1.5.0'
    );
    is cap { $build->probe }, 'share';
    is $build->runtime_prop->{version}, undef;
  };

};

subtest 'match_stderr + version_stderr' => sub {

  my $guard = system_fake
    'foo' => sub { print STDERR "Froodle Foomaker version 1.00\n"; return 0 },
  ;

  subtest 'match good' => sub {
    my($build) = build(command => 'foo', match_stderr => qr/Froodle/);
    is cap { $build->probe }, 'system';
  };

  subtest 'match bad' => sub {
    my($build) = build(command => 'foo', match_stderr => qr/Droodle/);
    is cap { $build->probe }, 'share';
  };

  subtest 'version found' => sub {
    my($build) = build(command => 'foo', version_stderr => qr/version ([0-9\.]+)/);
    is cap { $build->probe }, 'system';
    is $build->runtime_prop->{version}, '1.00';
  };

  subtest 'version unfound' => sub {
    my($build) = build(command => 'foo', version_stderr => qr/version = ([0-9\.]+)/);
    is cap { $build->probe }, 'system';
    is $build->runtime_prop->{version}, undef;
  };


};

done_testing;



( run in 0.626 second using v1.01-cache-2.11-cpan-acebb50784d )