Permalink
Browse files

Made the set of mutation operators a parameter in the core modules; t…

…hey are currently hard-coded in the mutation scripts, though.
  • Loading branch information...
rjust committed Aug 12, 2017
1 parent dcb7e46 commit aa6955bd6bab25f14a259c15b206ed8bdc36e418
@@ -133,14 +133,17 @@ if ($type eq "b") {
exit 1;
}
# The mutation operators that should be enabled
my @MUT_OPS = ("AOR", "LOR","SOR", "COR", "ROR", "ORU", "LVR", "STD");
# Instantiate project and set working directory
my $project = Project::create_project($pid);
$project->{prog_root} = $WORK_DIR;
# Classes to mutate -- default is all modified classes
my $classes = $INSTRUMENT // "$SCRIPT_DIR/projects/$pid/modified_classes/$bid.src";
$project->mutate($classes) > 0 or die "Cannot mutate project!";
$project->mutate($classes, \@MUT_OPS) > 0 or die "Cannot mutate project!";
my $log_file = "$WORK_DIR/.mutation.log";
# Run the test suite, according to the provided flags
@@ -131,6 +131,9 @@ =head1 DESCRIPTION
# Enable debugging if flag is set
$DEBUG = 1 if defined $cmd_opts{D};
# The mutation operators that should be enabled
my @MUT_OPS = ("AOR", "LOR","SOR", "COR", "ROR", "ORU", "LVR", "STD");
# Set up project
my $project = Project::create_project($PID);
@@ -285,7 +288,7 @@ sub _run_mutation {
close(EXCL_FILE);
}
my $gen_mutants = $project->mutate("$TARGET_CLASSES_DIR/$bid.src");
my $gen_mutants = $project->mutate("$TARGET_CLASSES_DIR/$bid.src", \@MUT_OPS);
$gen_mutants > 0 or die "No mutants generated for $vid!";
# Compile generated tests
View
@@ -54,22 +54,21 @@ my $SUMMARY_FILE = "summary.csv";
=head2 Static subroutines
Mutation::create_mml(instrument_classes, out_file)
Mutation::create_mml(instrument_classes, out_file, mut_ops)
Generates an mml file, enabling all mutation operators for all classes listed
in F<instrument_classes>.
Generates an mml file, enabling all mutation operators defined by the array
reference C<mut_ops> for all classes listed in F<instrument_classes>. The mml
(source) file is written to C<out_file>. This subroutine also compiles the mml
file to F<'out_file'.bin>.
=cut
sub create_mml {
@_ == 2 or die $ARG_ERROR;
my ($instrument_classes, $out_file) = @_;
@_ == 3 or die $ARG_ERROR;
my ($instrument_classes, $out_file, $mut_ops) = @_;
my $OUT_DIR = Utils::get_dir($out_file);
my $TEMPLATE = `cat $MAJOR_ROOT/mml/template.mml` or die "Cannot read mml template: $!";
# The mutation operators that should be enabled in the mml file
my @ops =("AOR", "LOR","SOR", "COR", "ROR", "ORU", "LVR", "STD");
system("mkdir -p $OUT_DIR");
open(IN, $instrument_classes);
@@ -84,7 +83,7 @@ sub create_mml {
foreach my $class (@classes) {
chomp $class;
print FILE "\n// Enable operators for $class\n";
foreach my $op (@ops) {
foreach my $op (@{$mut_ops}) {
# Skip disabled operators
next if $TEMPLATE =~ /-$op<"$class">/;
print FILE "$op<\"$class\">;\n";
View
@@ -692,15 +692,16 @@ sub coverage_report {
=pod
$project->mutate(instrument_classes)
$project->mutate(instrument_classes, mut_ops)
Mutates all classes listed in F<instrument_classes> in the checked-out program version.
Mutates all classes listed in F<instrument_classes>, using all mutation operators
defined by the array reference C<mut_ops>, in the checked-out program version.
Returns the number of generated mutants on success, -1 otherwise.
=cut
sub mutate {
@_ == 2 or die $ARG_ERROR;
my ($self, $instrument_classes) = @_;
@_ == 3 or die $ARG_ERROR;
my ($self, $instrument_classes, $mut_ops) = @_;
my $work_dir = $self->{prog_root};
# Read all classes that should be mutated
@@ -721,7 +722,7 @@ sub mutate {
my $mml_src = "$self->{prog_root}/.mml/default.mml";
my $mml_bin = "${mml_src}.bin";
Mutation::create_mml($instrument_classes, $mml_src);
Mutation::create_mml($instrument_classes, $mml_src, $mut_ops);
-e "$mml_bin" or die "Mml file does not exist: $mml_bin!";
# Set environment variable MML, which is read by Major
@@ -93,8 +93,11 @@ =head1 OPTIONS
$BID =~ /^(\d+)$/ or die "Wrong bug id format (\\d+): $BID!";
-e $CLASSES or die "File with classes to mutate does not exist: $CLASSES";
# The mutation operators that should be enabled
my @MU_OPS = ("AOR", "LOR","SOR", "COR", "ROR", "ORU", "LVR", "STD");
my $mml_src = "$OUT_DIR/$BID.mml";
my $mml_bin = "${mml_src}.bin";
Mutation::create_mml($CLASSES, $mml_src);
Mutation::create_mml($CLASSES, $mml_src, \@MUT_OPS);
-e "$mml_bin" or die "Mml file does not exist: $mml_bin!";

0 comments on commit aa6955b

Please sign in to comment.