Skip to content

Commit

Permalink
Simplified create_mml script: use functionality provided in Mutation …
Browse files Browse the repository at this point in the history
…module.
  • Loading branch information
rjust committed Aug 9, 2017
1 parent a99d664 commit bf5a6b9
Showing 1 changed file with 7 additions and 30 deletions.
37 changes: 7 additions & 30 deletions framework/util/create_mml.pl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ =head1 OPTIONS

use lib abs_path("$FindBin::Bin/../core");
use Constants;
use Mutation;
use Utils;

#
Expand All @@ -83,6 +84,7 @@ =head1 OPTIONS

pod2usage(1) unless defined $cmd_opts{p} and defined $cmd_opts{c} and defined $cmd_opts{o} and defined $cmd_opts{b};

# TODO: Unused parameter: PID
my $PID = $cmd_opts{p};
my $CLASSES = Utils::get_abs_path($cmd_opts{c});
my $OUT_DIR = Utils::get_abs_path($cmd_opts{o});
Expand All @@ -91,33 +93,8 @@ =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";

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, $CLASSES);
my @classes = <IN>;
close(IN);

my $file = "$OUT_DIR/$BID.mml";

# Generate mml file by enabling operators for listed classes only
open(FILE, ">$file") or die "Cannot write mml file ($file): $!";
# Add operator definitions from template
print FILE $TEMPLATE;
# Enable operators for all classes
foreach my $class (@classes) {
chomp $class;
print FILE "\n// Enable operators for $class\n";
foreach my $op (@ops) {
# Skip disabled operators
next if $TEMPLATE =~ /-$op<"$class">/;
print FILE "$op<\"$class\">;\n";
}
}
close(FILE);
my $log = `$MAJOR_ROOT/bin/mmlc $file 2>&1`;
$? == 0 or die "Cannot compile mml file: $file\n$log";
my $mml_src = "$OUT_DIR/$BID.mml";
my $mml_bin = "${mml_src}.bin";

Mutation::create_mml($CLASSES, $mml_src);
-e "$mml_bin" or die "Mml file does not exist: $mml_bin!";

0 comments on commit bf5a6b9

Please sign in to comment.