Project.pm -- interface and abstraction for all projects.
A specific project instance can be created with create_project(project_id)
.
use Project; my $pid=$ARGV[0]; my $project = Project::create_project($pid);
package Project::MyProject; use Constants; use Vcs::Git; # or Svn, etc. our @ISA = qw(Project); my $PID = "MyID"; sub new { my $class = shift; my $name = "my-project-name"; my $src = "src/main/java"; my $test = "src/test/java"; my $vcs = Vcs::Git->new($PID, "$REPO_DIR/$name.git", "$SCRIPT_DIR/projects/$PID/commit-db"); return $class->SUPER::new($name, $vcs, $src, $test); }
This module provides a general abstraction for attributes and subroutines of a project. Every submodule of Project represents one of the open source projects in the database.
JFreeChart (Vcs::Svn backend)
Closure compiler (Vcs::Git backend)
Commons lang (Vcs::Git backend)
Commons math (Vcs::Git backend)
Joda-time (Vcs::Git backend)
Project::create_project(project_id)
Dynamically loads the required submodule, instantiates the project, and returns a reference to it.
$project->{prog_name}
The program name of the project.
$project->{prog_root}
The root (working) directory for a checked-out program version of this project.
$project->print_info()
Prints all general and project-specific properties to STDOUT.
$project->src_dir(vid)
Returns the path to the directory of the source files for a given version id vid
. The returned path is relative to the working directory.
$project->test_dir(vid)
Returns the path to the directory of the junit test files for a given version id vid
. The returned path is relative to the working directory.
$project->exclude_tests_in_file(file, tests_dir)
Excludes all tests listed in file from the checked-out program version. The test sources must exist in the tests_dir
directory, which is relative to the working directory.
Tests are removed as follows:
$project->sanity_check()
Checks whether the project is correctly configured.
$project->checkout_vid(vid [, work_dir])
Checks out the provided version id (vid
) to work_dir, and tags the the buggy AND the fixed program version of this bug. Format of vid
: \d+[bf]
. The working directory (work_dir
) is optional, the default is prog_root
.
$project->compile([log_file])
Compiles the sources of the project version that is currently checked out. If log_file is provided, the compiler output is written to this file.
$project->compile_tests([log_file])
Compiles the tests of the project version that is currently checked out. If log_file is provided, the compiler output is written to this file.
$project->run_tests(result_file [, single_test])
Executes all developer-written tests in the checked-out program version. Failing tests are written to result_file
. If single_test
is provided, only this test method is run. Format of single_test
: <classname>::<methodname>.
$project->run_relevant_tests(result_file)
Executes only developer-written tests that are relevant to the bug of the checked-out program version. Failing tests are written to result_file
.
$project->compile_ext_tests(test_dir [, log_file])
Compiles an external test suite (e.g., a generated test suite) whose sources are located in test_dir against the project version that is currently checked out. If log_file is provided, the compiler output is written to this file.
$project->run_ext_tests(test_dir, test_include, result_file [, single_test])
Execute all of the tests in test_dir that match the pattern test_include
. Failing tests are written to result_file. If single_test
is provided, only this test method is executed. Format of single_test
: <classname>::<methodname>.
$project->fix_tests(vid)
Removes all broken tests in the checked-out program version. Which tests are broken and removed is determined based on the provided version id vid
: all tests listed in $SCRIPT_DIR/projects/$PID/failing_tests/rev-id are removed.
$project->monitor_test(single_test, vid [, test_dir])
Executes single_test
, monitors the class loader, and returns a reference to a hash of list references, which store the loaded source and test classes. Format of single_test
: <classname>::<methodname>.
This subroutine returns a reference to a hash with the keys src
and test
:
{src} => [org.foo.Class1 org.bar.Class2] {test} => [org.foo.TestClass1 org.foo.TestClass2]
If the test execution fails, the returned reference is undef
.
A class is included in the result if it exists in the source or test directory of the checked-out program verion and if it was loaded during the test execution.
The location of the test sources can be provided with the optional parameter test_dir. The default is the test directory of the developer-written tests.
$project->coverage_instrument(instrument_classes)
Instruments classes listed in instrument_classes for use with cobertura.
$project->coverage_report(source_dir)
TODO
$project->mutate()
Mutates the checked-out program version. Returns the number of generated mutants on success, -1 otherwise.
$project->mutation_analysis(log_file, relevant_tests [, single_test])
Performs mutation analysis for the developer-written tests of the checked-out program version. The output of the mutation analysis process is redirected to log_file, and the boolean parameter relevant_tests
indicates whether only relevant test cases are executed. If single_test
is specified, only that test is run.
Note that mutate
is not called implicitly.
$project->mutation_analysis_ext(test_dir, test_include, log_file [, single_test])
Performs mutation analysis for all tests in test_dir that match the pattern test_include
. The output of the mutation analysis process is redirected to log_file. If single_test
is specified, only that test is run.
Note that mutate
is not called implicitly.
$project->run_evosuite(target_criterion, target_time, target_class, assertion_timeout, config_file [, log_file])
Runs EvoSuite on the checked-out program version.
$project->run_randoop(target_classes, timeout, seed, config_file [, log_file])
Runs Randoop on the checked-out program version.
The following delegate subroutines are implemented merely for convenience.
$project->lookup(version_id)
Delegate to the VCS backend.
$project->num_revision_pairs()
Delegate to the VCS backend.
$project->get_version_ids()
Delegate to the VCS backend.
$project->contains_version_id(vid)
Delegate to the VCS backend.
$project->diff(revision_id_1, revision_id_2 [, path])
Delegate to the VCS backend.
$project->export_diff(revision_id_1, revision_id_2, out_file [, path])
Delegate to the VCS backend.
$project->apply_patch(work_dir, patch_file)
Delegate to the VCS backend.