Unverified Commit d02913b2 authored by boklm's avatar boklm
Browse files

Strip code refs before exporting to json

When exporting test options to json on mozmill tests.
parent 7c89dafa
......@@ -12,7 +12,7 @@ use File::Copy;
use JSON;
use Digest::SHA qw(sha256_hex);
use LWP::UserAgent;
use TBBTestSuite::Common qw(exit_error winpath);
use TBBTestSuite::Common qw(exit_error winpath clone_strip_coderef);
use TBBTestSuite::Options qw($options);
use TBBTestSuite::Tests::VirusTotal qw(virustotal_run);
use TBBTestSuite::Tests::Command qw(command_run);
......@@ -427,8 +427,8 @@ sub ffbin_path {
sub mozmill_export_options {
my ($tbbinfos, $test) = @_;
my $options_file = winpath("$FindBin::Bin/mozmill-tests/lib/testsuite.js");
my $json_opts = encode_json $options;
my $json_test = encode_json $test;
my $json_opts = encode_json clone_strip_coderef $options;
my $json_test = encode_json clone_strip_coderef $test;
my $content = <<EOF;
var options = $json_opts;
var test = $json_test;
......
......@@ -7,13 +7,15 @@ use FindBin;
use IO::CaptureOutput qw(capture_exec);
use File::Slurp;
use IPC::Run qw(run);
use Storable qw(dclone);
our (@ISA, @EXPORT_OK);
BEGIN {
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(exit_error system_infos run_alone rm_pidfile winpath
has_bin get_var run_to_file get_nbcpu as_array);
has_bin get_var run_to_file get_nbcpu as_array
clone_strip_coderef);
}
sub exit_error {
......@@ -94,4 +96,13 @@ sub as_array {
ref $_[0] eq 'ARRAY' ? $_[0] : [ $_[0] ];
}
# clone a data structure, stripping code references
sub clone_strip_coderef {
my ($in) = @_;
local $Storable::Deparse = 0;
local $Storable::forgive_me = 1;
local $SIG{__WARN__} = sub {};
return dclone $in;
}
1;
......@@ -27,7 +27,7 @@ perlmodules='
Cwd Data::Dump Digest::SHA File::Path File::Slurp File::Spec File::Temp
FindBin Getopt::Long IO::CaptureOutput IO::Socket::INET Image::Magick
JSON LWP::UserAgent LWP::Protocol::https Template YAML::Syck DateTime
Email::Simple Email::Sender File::Type IPC::Run XML::LibXML
Email::Simple Email::Sender File::Type IPC::Run XML::LibXML Storable
'
if [ -f /etc/debian_version ]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment