<commit_before>#! perl
# Copyright (C) 2007-2008, Parrot Foundation.
# $Id$
# gen/platform-01.t

use strict;
use warnings;
use Test::More tests => 13;
use Carp;
use Cwd;
use File::Copy;
use File::Path qw( mkpath );
use File::Temp qw( tempdir );
use File::Spec;
use lib qw( lib );
use_ok('config::gen::platform');
use Parrot::Configure::Options qw( process_options );
use Parrot::Configure::Step::Test;
use Parrot::Configure::Test qw(
    test_step_constructor_and_description
);
use Parrot::Configure::Utils qw( _slurp );
use IO::CaptureOutput qw( capture );

########## regular ##########

my ($args, $step_list_ref) = process_options(
    {
        argv => [ ],
        mode => q{configure},
    }
);

my $conf = Parrot::Configure::Step::Test->new;
$conf->include_config_results( $args );

my $pkg = q{gen::platform};
$conf->add_steps($pkg);
$conf->options->set( %{$args} );
my $step = test_step_constructor_and_description($conf);

ok(-f $step->{platform_interface},
    "Located required platform interface header");

my $platform_orig = $conf->data->get('osname');
my $archname_orig = $conf->data->get('archname');
$conf->data->set( archname => 'foo-bar' );
my $verbose = 0;

########## _get_generated() ##########

my $TEMP_generated_orig = $conf->data->get('TEMP_generated');
{
    $verbose = 1;
    my ($stdout, $stderr, $rv);
    my $expected = q{foo};
    $conf->data->set( TEMP_generated => $expected );
    capture(
        sub { $rv = $step->_get_generated( $conf, $verbose ) },
        \$stdout,
        \$stderr,
    );
    is( $rv, $expected, "Got expected generated");
    like( $stdout, qr/\($expected\)/, "Got expected verbose output");
}
$conf->data->set( TEMP_generated => undef );
$verbose = 0;
is( $step->_get_generated( $conf, $verbose ), q{},
    "Got expected generated");

# re-set to original values
$conf->data->set( TEMP_generated => $TEMP_generated_orig );<commit_msg>fix config test forgotten when eliminating generation of platform_interface.h<commit_after>#! perl
# Copyright (C) 2007-2008, Parrot Foundation.
# $Id$
# gen/platform-01.t

use strict;
use warnings;
use Test::More tests => 12;
use Carp;
use Cwd;
use File::Copy;
use File::Path qw( mkpath );
use File::Temp qw( tempdir );
use File::Spec;
use lib qw( lib );
use_ok('config::gen::platform');
use Parrot::Configure::Options qw( process_options );
use Parrot::Configure::Step::Test;
use Parrot::Configure::Test qw(
    test_step_constructor_and_description
);
use Parrot::Configure::Utils qw( _slurp );
use IO::CaptureOutput qw( capture );

########## regular ##########

my ($args, $step_list_ref) = process_options(
    {
        argv => [ ],
        mode => q{configure},
    }
);

my $conf = Parrot::Configure::Step::Test->new;
$conf->include_config_results( $args );

my $pkg = q{gen::platform};
$conf->add_steps($pkg);
$conf->options->set( %{$args} );
my $step = test_step_constructor_and_description($conf);

my $platform_orig = $conf->data->get('osname');
my $archname_orig = $conf->data->get('archname');
$conf->data->set( archname => 'foo-bar' );
my $verbose = 0;

########## _get_generated() ##########

my $TEMP_generated_orig = $conf->data->get('TEMP_generated');
{
    $verbose = 1;
    my ($stdout, $stderr, $rv);
    my $expected = q{foo};
    $conf->data->set( TEMP_generated => $expected );
    capture(
        sub { $rv = $step->_get_generated( $conf, $verbose ) },
        \$stdout,
        \$stderr,
    );
    is( $rv, $expected, "Got expected generated");
    like( $stdout, qr/\($expected\)/, "Got expected verbose output");
}
$conf->data->set( TEMP_generated => undef );
$verbose = 0;
is( $step->_get_generated( $conf, $verbose ), q{},
    "Got expected generated");

# re-set to original values
$conf->data->set( TEMP_generated => $TEMP_generated_orig );
{'fraction_non_alphanumeric': 0.2, 'fraction_numerical': 0.007947019867549669, 'mean_word_length': 4.536656891495602, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7526066', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1291, 'n_words': 309}