- Notifications
You must be signed in to change notification settings - Fork 194
/
Copy path00_setup.t
126 lines (99 loc) · 3.18 KB
/
00_setup.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
use strict;
use warnings;
use lib 't/lib';
use CPAN::Faker 0.010 ();
use Devel::Confess;
use MetaCPAN::Script::Tickets ();
use MetaCPAN::TestHelpers qw(
fakecpan_configs_dir
fakecpan_dir
get_config
tmp_dir
write_find_ls
);
use MetaCPAN::TestServer ();
use Test::More 0.96;
use URI::FromHash qw( uri );
BEGIN {
# We test parsing bad YAML. This attempt emits a noisy warning which is not
# helpful in test output, so we'll suppress it here.
$SIG{__WARN__} = sub {
my$msg = shift;
returnif$msg =~ m{found a duplicate key};
warn$msg;
};
}
# Ensure we're starting fresh
my$tmp_dir = tmp_dir();
$tmp_dir->remove_tree( { safe=> 0 } );
$tmp_dir->mkpath;
ok( $tmp_dir->stat, "$tmp_dir exists for testing" );
my$server = MetaCPAN::TestServer->new;
$server->setup;
# Run the Mappings Tests
$server->test_mappings;
my$config = get_config();
$config->{es} = $server->es_client;
my$mod_faker = 'Module::Faker::Dist::WithPerl';
eval"require $mod_faker"ordie$@; ## no critic (StringyEval)
my$fakecpan_dir = fakecpan_dir();
$fakecpan_dir->remove_tree;
$fakecpan_dir = fakecpan_dir(); # recreate dir
my$fakecpan_configs = fakecpan_configs_dir();
my$cpan = CPAN::Faker->new( {
source=>$fakecpan_configs->child('configs')->stringify,
dest=>$fakecpan_dir->stringify,
dist_class=>$mod_faker,
} );
ok( $cpan->make_cpan, 'make fake cpan' );
$fakecpan_dir->child('authors')->mkpath;
$fakecpan_dir->child('indices')->mkpath;
# make some changes to 06perms.txt
{
my$perms_file = $fakecpan_dir->child('modules')->child('06perms.txt');
my$perms = $perms_file->slurp;
$perms =~ s/^Some,LOCAL,f$/Some,MO,f/m;
my$fh = $perms_file->openw;
print$fh$perms;
# Temporary hack. Remove after DarkPAN 06perms generation is fixed.
print$fh'CPAN::Test::Dummy::Perl5::VersionBump,MIYAGAWA,f', "\n";
print$fh'CPAN::Test::Dummy::Perl5::VersionBump,OALDERS,c', "\n";
close$fh;
}
# Help debug inconsistent parsing failures.
use Parse::PMFile ();
local$Parse::PMFile::VERBOSE = $ENV{TEST_VERBOSE} ? 9 : 0;
my$src_dir = $fakecpan_configs;
$src_dir->child('00whois.xml')
->copy( $fakecpan_dir->child(qw(authors 00whois.xml)) );
$src_dir->child('author-1.0.json')
->copy( $fakecpan_dir->child(qw(authors id M MO MO author-1.0.json)) );
$src_dir->child('bugs.tsv')->copy( $fakecpan_dir->child('bugs.tsv') );
$src_dir->child('mirrors.json')
->copy( $fakecpan_dir->child(qw(indices mirrors.json)) );
$src_dir->child('08pumpkings.txt.gz')
->copy( $fakecpan_dir->child(qw(authors 08pumpkings.txt.gz)) );
write_find_ls($fakecpan_dir);
$server->index_permissions;
$server->index_packages;
$server->index_releases;
$server->set_latest;
$server->set_first;
$server->index_authors;
$server->prepare_user_test_data;
$server->index_cpantesters;
$server->index_mirrors;
$server->index_favorite;
$server->index_cover;
ok(
MetaCPAN::Script::Tickets->new_with_options( {
%{$config},
rt_summary_url=> uri(
scheme=>'file',
path=>$fakecpan_dir->child('bugs.tsv')->absolute->stringify,
),
} )->run,
'tickets'
);
$server->wait_for_es();
done_testing;