1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use Test::More tests => 16;
6
7use TAP::Harness::Env;
8
9sub _has_module {
10    my $module = shift;
11    eval "use $module";
12    return $@ ? 0 : 1;
13}
14
15{
16
17    # Should add a fake home dir? to test the rc stuff..
18    local $ENV{HARNESS_OPTIONS} = 'j4:c';
19
20    ok my $harness = TAP::Harness::Env->create, 'made harness';
21    is( $harness->color, 1, "set color correctly" );
22    is( $harness->jobs,  4, "set jobs correctly" );
23}
24SKIP: {
25    skip "requires TAP::Formatter::HTML", 4
26      unless _has_module('TAP::Formatter::HTML');
27    skip "requires TAP::Formatter::HTML 0.10 or higher", 4
28        unless TAP::Formatter::HTML->VERSION >= .10;
29
30    local $ENV{HARNESS_OPTIONS} = 'j4:c:fTAP-Formatter-HTML';
31
32    ok my $harness = TAP::Harness::Env->create, 'made harness';
33    is( $harness->color, 1, "set color correctly" );
34    is( $harness->jobs,  4, "set jobs correctly" );
35    is( $harness->formatter_class, "TAP::Formatter::HTML",
36        "correct formatter" );
37
38}
39SKIP: {
40    skip "requires TAP::Harness::Archive", 5
41      unless _has_module('TAP::Harness::Archive');
42
43    # Test archive
44    local $ENV{HARNESS_OPTIONS} = 'j4:c:a/archive.tgz';
45
46    ok my $harness = TAP::Harness::Env->create, 'made harness';
47    is( $harness->color, 1, "set color correctly" );
48    is( $harness->jobs,  4, "set jobs correctly" );
49    isa_ok( $harness, "TAP::Harness::Archive", "correct harness subclass" );
50
51    # XXX: this is nasty :(
52    is( $harness->{__archive_file}, "/archive.tgz", "correct archive found" );
53
54}
55
56{
57    local $ENV{HARNESS_TIMER} = 0;
58    ok my $harness = TAP::Harness::Env->create, 'made harness';
59    ok !$harness->timer, 'timer set via HARNESS_TIMER';
60}
61
62{
63    local $ENV{HARNESS_TIMER} = 1;
64    ok my $harness = TAP::Harness::Env->create, 'made harness';
65    ok $harness->timer, 'timer set via HARNESS_TIMER';
66}
67