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 $vcs = Vcs::Git->new($PID, "$REPO_DIR/$name.git", "$PROJECTS_DIR/$PID/$BUGS_CSV_ACTIVE"); return $class->SUPER::new($PID, $name, $vcs); }
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)
Commons CLI (Vcs::Git backend)
Closure compiler (Vcs::Git backend)
Commons Codec (Vcs::Git backend)
Commons Collections (Vcs::Git backend)
Commons Compress (Vcs::Git backend)
Commons CSV (Vcs::Git backend)
Google Gson (Vcs::Git backend)
Jackson JSON Parser (Vcs::Git backend)
Jackson Data Bindings (Vcs::Git backend)
Jackson XML Parser (Vcs::Git backend)
Jsoup HTML Parser (Vcs::Git backend)
Commons JxPath (Vcs::Git backend)
Commons lang (Vcs::Git backend)
Commons math (Vcs::Git backend)
Mockito (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->bug_report_id()
Returns the bug report ID of a given version id vid
.
$project->bug_report_url()
Returns the bug report URL of a given version id vid
.
$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, is_bugmine])
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 temporary working directory (work_dir
) is optional, the default is prog_root
from the instance of this class. The is_bugmine flag (is_bugmine
) is optional and indicates whether the framework is used for bug mining, the default is false.
$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 $PROJECTS_DIR/$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 version 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(instrument_classes, mut_ops)
Mutates all classes listed in instrument_classes, using all mutation operators defined by the array reference mut_ops
, in the checked-out program version. Returns the number of generated mutants on success, -1 otherwise.
$project->mutation_analysis(log_file, relevant_tests [, exclude_file, 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 [, exclude_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.
The following delegate subroutines are implemented merely for convenience.
$project->lookup(version_id)
Delegate to the Vcs backend.
$project->lookup_vid(revision_id)
Delegate to the Vcs backend.
$project->num_revision_pairs()
Delegate to the Vcs backend.
$project->get_bug_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.