Skip to content

Instantly share code, notes, and snippets.

@simonbates
Last active March 21, 2018 17:52
Show Gist options
  • Save simonbates/a6d3f6906f0e8f5ebaa1844003245c4d to your computer and use it in GitHub Desktop.
Save simonbates/a6d3f6906f0e8f5ebaa1844003245c4d to your computer and use it in GitHub Desktop.
A Perl script to repeatedly run GPII/universal/tests/all-tests.js
# A Perl script to repeatedly run GPII/universal/tests/all-tests.js
#
# Run with: perl run_all_tests
#
# Assumes that it is being run in the 'universal' directory.
# Test run output will be written to files in dircetory 'all-tests_out'.
#
# NOTE: This script deletes the 'browserify' and 'node_modules'
# directories before each run.
use strict;
use warnings;
use File::Path 'remove_tree';
use File::Spec;
use Time::Piece;
my $num_runs = 30;
my $all_tests = File::Spec->catfile('tests', 'all-tests.js');
my $outdir = 'all-tests_out';
sub run_shell_command {
my $command = shift(@_);
print("$command\n");
system($command);
}
mkdir($outdir);
for (my $i = 0; $i < $num_runs; $i++) {
my $datetime = localtime->datetime;
my $outfile = File::Spec->catfile($outdir, "all-tests_$datetime.txt");
# Clean the working directory
remove_tree('browserify');
remove_tree('node_modules');
# npm install and run tests
run_shell_command("npm install > '$outfile' 2>&1");
run_shell_command("node $all_tests >> '$outfile' 2>&1");
sleep(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment