Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
tor-browser-bundle-testsuite
Commits
a1a43e62
Unverified
Commit
a1a43e62
authored
Feb 25, 2014
by
boklm
Browse files
If filename is a URL, download it
parent
21ec7452
Changes
1
Hide whitespace changes
Inline
Side-by-side
tbb-testsuite
View file @
a1a43e62
...
...
@@ -6,6 +6,7 @@ use File::Spec;
use
File::
Temp
;
use
Data::
Dump
qw/dd/
;
use
FindBin
;
use
LWP::
UserAgent
;
my
%default_options
=
(
language
=>
'
en-US
',
...
...
@@ -26,6 +27,22 @@ sub get_options {
return
\
%res
;
}
sub
get_tbbfile
{
my
(
$tbbfile
)
=
@_
;
if
(
$tbbfile
=~
m/^https?:\/\//
)
{
print
"
Downloading
$tbbfile
\n
";
my
(
undef
,
undef
,
$file
)
=
File::
Spec
->
splitpath
(
$tbbfile
);
my
$output
=
"
$options
->{tbbinfos}{tmpdir}/
$file
";
my
$ua
=
LWP::
UserAgent
->
new
;
my
$resp
=
$ua
->
get
(
$tbbfile
,
'
:content_file
'
=>
$output
);
exit_error
"
Error downloading
$tbbfile
:
\n
"
.
$resp
->
status_line
unless
$resp
->
is_success
;
return
$output
;
}
exit_error
"
File
$tbbfile
does not exist
"
unless
-
f
$tbbfile
;
return
$tbbfile
;
}
sub
tbb_filename_infos
{
my
(
$tbbfile
)
=
@_
;
my
(
undef
,
undef
,
$file
)
=
File::
Spec
->
splitpath
(
$tbbfile
);
...
...
@@ -51,8 +68,7 @@ sub extract_tbb {
my
(
$tbbfile
)
=
@_
;
exit_error
"
Can't open file
$tbbfile
"
unless
-
f
$tbbfile
;
$tbbfile
=
File::
Spec
->
rel2abs
(
$tbbfile
);
my
$oldcwd
=
getcwd
;
my
$tmpdir
=
File::Temp::
newdir
('
tbbXXXXX
',
CLEANUP
=>
0
);
my
$tmpdir
=
$options
->
{
tbbinfos
}{
tmpdir
};
chdir
$tmpdir
;
system
('
tar
',
'
xf
',
$tbbfile
);
return
"
$tmpdir
/tor-browser_
$options
->{tbbinfos}{language}
";
...
...
@@ -95,6 +111,8 @@ sub test_tbb {
my
(
$tbbfile
)
=
@_
;
my
$oldcwd
=
getcwd
;
$options
->
{
tbbinfos
}
=
tbb_filename_infos
(
$tbbfile
);
$options
->
{
tbbinfos
}{
tmpdir
}
=
File::Temp::
newdir
;
$tbbfile
=
get_tbbfile
(
$tbbfile
);
$options
->
{
tbbdir
}
=
extract_tbb
(
$tbbfile
);
chdir
$options
->
{
tbbdir
}
||
exit_error
"
Can't enter directory
$options
->{tbbdir}
";
setup_tbb
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment