<commit_before>#! perl
# Copyright (C) 2010, Parrot Foundation.
# 062-sha1_to_cache.t

use strict;
use warnings;

use Test::More;
if (-e 'DEVELOPING' and ! -e 'Makefile') {
    plan tests =>  8;
}
else {
    plan skip_all =>
        q{Relevant only when working in a development repo and prior to configuration};
}
use Carp;
use Cwd;
use File::Copy;
use File::Path ();
use File::Temp qw| tempdir |;
use lib qw( lib );

my $cwd = cwd();
{
    my $tdir = tempdir( CLEANUP => 1 );
    ok( chdir $tdir, "Changed to temporary directory for testing" );
    my $libdir = qq{$tdir/lib};
    ok( (File::Path::mkpath( [ $libdir ], 0, 0777 )), "Able to make libdir");
    local @INC;
    unshift @INC, $libdir;
    ok( (File::Path::mkpath( [ qq{$libdir/Parrot} ], 0, 0777 )), "Able to make Parrot dir");
    require Parrot::Git::Describe;
    {
        no warnings 'once';
        TODO: {
        ok( (copy qq{$cwd/lib/Parrot/Git/Describe.pm},
                qq{$libdir/Parrot}), "Able to copy Parrot::Git::Describe");

            like($Parrot::Git::Describe::current,
                qr/^(RELEASE_|REL_)\d+\.\d+\.\d+~g[a-z0-9]+$/i,
                "Got a describe string",
            );
        };
    }
    my $cache = q{.parrot_current_git_describe};
    my $size = -s $cache;
    cmp_ok( $size , '>', 0, "Cache for sha1 number was created and nonempty : $size bytes");

    chdir $tdir;
    unlink qq{$libdir/Parrot/Git/Describe.pm}
        or croak "Unable to delete file after testing";
    ok( chdir $cwd, "Able to change back to starting directory");
}

pass("Completed all tests in $0");

=head1 NAME

062-git_describe_to_cache.t - test caching in Parrot::Git::Describe

=head1 SYNOPSIS

    % prove t/configure/063-sha1_to_cache.t

=head1 DESCRIPTION

The files in this directory test functionality used by F<Configure.pl>.<commit_msg>[config] Make the git_describe cache tests pass<commit_after>#! perl
# Copyright (C) 2010, Parrot Foundation.
# 062-sha1_to_cache.t

use strict;
use warnings;

use Test::More;
if (-e 'DEVELOPING' and ! -e 'Makefile') {
    plan tests =>  8;
}
else {
    plan skip_all =>
        q{Relevant only when working in a development repo and prior to configuration};
}
use Carp;
use Cwd;
use File::Copy;
use File::Path ();
use File::Temp qw| tempdir |;
use lib qw( lib );

my $cwd = cwd();
{
    my $tdir = tempdir( CLEANUP => 1 );
    ok( chdir $tdir, "Changed to temporary directory for testing" );
    my $libdir = qq{$tdir/lib};
    ok( (File::Path::mkpath( [ $libdir ], 0, 0777 )), "Able to make libdir");

    # Can't get it to work with this. Why do we need it?
    #local @INC;

    unshift @INC, $libdir;
    ok( (File::Path::mkpath( [ qq{$libdir/Parrot/Git} ], 0, 0777 )), "Able to make Parrot dir");
    chdir $cwd;

    require Parrot::Git::Describe;
    {
        no warnings 'once';
        TODO: {
        ok( (copy qq{$cwd/lib/Parrot/Git/Describe.pm},
                qq{$libdir/Parrot/Git}), "Able to copy Parrot::Git::Describe");

            like($Parrot::Git::Describe::current,
                qr/^(RELEASE_|REL_)\d+\_\d+\_\d+\-\d+\-g[a-z0-9]+$/i,
                "Got a describe string",
            );
        };
    }
    my $cache = q{.parrot_current_git_describe};
    my $size = -s $cache;
    cmp_ok( $size , '>', 0, "Cache for sha1 number was created and nonempty : $size bytes");

    chdir $tdir;
    unlink qq{$libdir/Parrot/Git/Describe.pm}
        or croak "Unable to delete file after testing";
    ok( chdir $cwd, "Able to change back to starting directory");
}

pass("Completed all tests in $0");

=head1 NAME

062-git_describe_to_cache.t - test caching in Parrot::Git::Describe

=head1 SYNOPSIS

    % prove t/configure/063-sha1_to_cache.t

=head1 DESCRIPTION

The files in this directory test functionality used by F<Configure.pl>.
{'fraction_non_alphanumeric': 0.1500394840747565, 'fraction_numerical': 0.018425901553040275, 'mean_word_length': 2.8578680203045685, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '1200252', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1347, 'n_words': 395}