Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge bug mining into master #135

Merged
merged 277 commits into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from 244 commits
Commits
Show all changes
277 commits
Select commit Hold shift + click to select a range
d26bfac
slight modifications for build script
tomecho Nov 21, 2017
d36c950
fix a few little things making them work a little better
tomecho Nov 21, 2017
2f83bf8
adjust some of these variables
tomecho Nov 21, 2017
73e76b9
might not even use this bugmine.stanity.check after all, it seeps to …
tomecho Nov 21, 2017
4fcb412
clean that up
tomecho Nov 21, 2017
2e46c50
document that and remove dummy param, it was silly anyway
tomecho Nov 30, 2017
57c67d9
update some basic project lib stuff
tomecho Nov 30, 2017
a350f8d
update paths on that and remove trailing spaces and backslashes
tomecho Dec 1, 2017
b842762
be a little more verbose when skipping existing entries
tomecho Dec 1, 2017
71c503a
its acutally just trigger not triggering
tomecho Dec 5, 2017
b5d1b62
all ant tasks return boolean for success not a return status code
tomecho Dec 6, 2017
44dc945
adapt this a little
tomecho Dec 6, 2017
9473a7b
fix issues that cause obvious failure, still failing now but just not…
tomecho Dec 7, 2017
0ebcd42
Merge branch 'master' of github.com:rjust/defects4j into merge-bug-mi…
tomecho Dec 21, 2017
e0b1da5
fix get class list and update readme to reflect any changes to bug mi…
tomecho Dec 21, 2017
16304c6
move depenency module list into main readme, add glossary to main readme
tomecho Dec 22, 2017
d781923
update paths one last time
tomecho Dec 22, 2017
f0205dc
minimize patch and promote to directory scripts updated
tomecho Dec 22, 2017
1ca2931
copy notice about new build file location
tomecho Dec 22, 2017
a141260
update method fingerpring
tomecho Dec 22, 2017
1564511
remind myself to remove this
tomecho Dec 22, 2017
0f91c3b
remove framework/build-scripts
tomecho Dec 22, 2017
c0fcd9c
copy overview to main readme
tomecho Dec 30, 2017
c9faafd
Merge branch 'master' of github.com:rjust/defects4j into merge-bug-mi…
tomecho Feb 4, 2018
b6f53b5
dont need to just diff the src directory
tomecho Feb 5, 2018
a05df49
assign args explicitly rather than just shift a bunch of times
tomecho Feb 5, 2018
88c5487
Revert "assign args explicitly rather than just shift a bunch of times"
tomecho Feb 5, 2018
9550bb2
Revert "Revert "assign args explicitly rather than just shift a bunch…
tomecho Feb 5, 2018
c0e745d
do the same in the lang project module
tomecho Feb 5, 2018
8d5b1fb
bugmine.sanity.check was just for testing, it isnt even used now, can…
tomecho Feb 5, 2018
a612c5a
update comment
tomecho Feb 5, 2018
5464a93
Revert change in string interpolation syntax
tomecho Feb 8, 2018
a50c17c
In project.pm checkout_id update variable name and comment
tomecho Feb 8, 2018
b71541f
Updated a comment in Project module.
rjust Feb 8, 2018
86a31c8
Removed a delegation method: checkout_vid is already implemented and …
rjust Feb 8, 2018
39eeb57
Some simplifications and consistency changes.
rjust Feb 8, 2018
f2ca10d
Consistently use the work directory, if provided.
rjust Feb 8, 2018
31259cf
Merge https://github.com/rjust/defects4j into merge-bug-mining-into-m…
rjust Feb 8, 2018
2b80984
Infer commit-db and build file location from work_dir; expect work_di…
rjust Feb 8, 2018
b40294a
Let ant report that error
tomecho Feb 9, 2018
90b77a6
Merge branch 'merge-bug-mining-into-master' of github.com:tomecho/def…
tomecho Feb 9, 2018
a53f1cd
Remove outdated comment
tomecho Feb 9, 2018
b58b46d
Fixed broken Project module.
rjust Feb 9, 2018
2afd27e
Merge branch 'merge-bug-mining-into-master' of https://github.com/tom…
rjust Feb 9, 2018
102976c
Added another variable for the projects directory.
rjust Feb 9, 2018
8a8250d
Started removing the work_dir attribute, which is replaced by a globa…
rjust Feb 9, 2018
0b8024e
Remove failing, flaky, and random tests in Project module.
rjust Feb 9, 2018
94194ec
More fixes in core Modules; dynamically determine the directory layout.
rjust Feb 9, 2018
2165331
Added the adapted build.xml template.
rjust Feb 9, 2018
9286fd4
Updated Project template.
rjust Feb 9, 2018
6324908
Updated create-project.pl.
rjust Feb 9, 2018
01bc904
Renamed directory mapping for Math.
rjust Feb 9, 2018
79a3e9f
Updated Math and Lang project modules.
rjust Feb 9, 2018
a8b91e4
Made template consistent with Lang and Math project modules.
rjust Feb 9, 2018
99a2696
Updated the documentation.
rjust Feb 9, 2018
45fabdf
Updated two more scripts, which still require some fine tuning.
rjust Feb 9, 2018
74c274b
Updated the core framework to support bootstrapping in the bug-mining…
rjust Feb 9, 2018
8cdfe14
Don't hard-code the location of the project build file.
rjust Feb 9, 2018
8051368
Fixed init script; create all necessary dirs in the create-project sc…
rjust Feb 9, 2018
b85089f
Pass over documentation.
rjust Feb 9, 2018
88deeeb
Fixed a layout issue.
rjust Feb 9, 2018
0ec7b5f
Skip invalid candidates.
rjust Feb 9, 2018
5921c41
Fixed a typo.
rjust Feb 9, 2018
137fdec
Improved script documentation; consistently use -b for bug ids.
rjust Feb 9, 2018
190f1ea
Tweaked the README.
rjust Feb 9, 2018
5ef5ad7
Minor fixes and output tweaks.
rjust Feb 9, 2018
bee5287
Clone the repo when creating the project.
rjust Feb 9, 2018
b7ebfc3
More documentation improvements.
rjust Feb 9, 2018
4bb46c3
Updated the get-trigger script; tweaked perldoc of analyze-project sc…
rjust Feb 10, 2018
6ad0a05
More documentation updates.
rjust Feb 10, 2018
30fa355
Merge branch 'master' of https://github.com/rjust/defects4j into merg…
rjust Feb 10, 2018
173b550
Removed PatchReader from get-class-list script and updated documentat…
rjust Feb 10, 2018
fe6dc90
Pass over main README.
rjust Feb 10, 2018
3dd5203
Create all directories when setting up a project; properly set D4J co…
rjust Feb 10, 2018
52e24ea
Merge https://github.com/rjust/defects4j into merge-bug-mining-into-m…
rjust Feb 10, 2018
29842ba
PatchReader is no longer required.
rjust Feb 10, 2018
3c907d3
Update the project_repos README after cloning the repo.
rjust Feb 10, 2018
07feffc
Updated the minimize-patch script.
rjust Feb 10, 2018
7bc7d00
Updated file headers.
rjust Feb 10, 2018
21a338f
Minimize changes in the PR since we eliminated the confusing use of p…
rjust Feb 10, 2018
33042aa
More prog_root -> work_dir changes.
rjust Feb 10, 2018
234418e
Updated Chart project module.
rjust Feb 11, 2018
f7f91bd
Added the init subroutine, which is called by the bug-mining scripts,…
rjust Feb 11, 2018
bd0421b
Updated documentation.
rjust Feb 11, 2018
5a97e08
prog_root -> work_dir.
rjust Feb 11, 2018
c0fa88d
Fixed Chart project module.
rjust Feb 11, 2018
113ba0d
Don't apply co_hook in Vcs module.
rjust Feb 11, 2018
cb86dac
Reverted changes that are no longer required.
rjust Feb 11, 2018
8264efa
Added the cached directory layout map for Chart.
rjust Feb 11, 2018
45c709a
More information about locales (addresses #129).
rjust Feb 13, 2018
3ef0cac
Don't hard-code paths to meta data in util scripts.
rjust Feb 15, 2018
8d796d0
Properly set environment variables in get-class-list script.
rjust Feb 15, 2018
2e4cfd3
Run fewer bugs for Math to avoid travis timeouts.
rjust Feb 15, 2018
ebf91b3
Added a todo in the Project module.
rjust Feb 17, 2018
dbe9be5
Updated Time module.
rjust Feb 17, 2018
182ba6d
Use revision IDs to identify broken builds in Time.
rjust Feb 17, 2018
5c9bf26
Temporarily disable a couple tests.
rjust Feb 17, 2018
2cdfe92
Some build files in Time are broken; added the functionality back in …
rjust Feb 17, 2018
6685e73
Added the generated directory layout map.
rjust Feb 17, 2018
baca487
Renamed Mockito files.
rjust Feb 17, 2018
3d719a0
Added a todo.
rjust Feb 17, 2018
1e7318a
Renamed a subroutine.
rjust Feb 17, 2018
5b7e8cf
Updated Mockito module.
rjust Feb 17, 2018
cb77957
Improved project module template.
rjust Feb 17, 2018
7a19b91
Updated Closure module.
rjust Feb 17, 2018
22c1980
More descriptive names for build stages.
rjust Feb 17, 2018
1db2d34
Fixed a typo in travis config; allocate more time for Closure defects.
rjust Feb 17, 2018
348a2f5
Fixed a regex typo.
rjust Feb 18, 2018
da5704a
Added the directory layout for Closure.
rjust Feb 18, 2018
86bf4c4
Final dir-layout for Closure.
rjust Feb 18, 2018
1ed6803
Added one more test that fails non-deterministically on Travis.
rjust Feb 18, 2018
a6e8273
Moved glossary of D4J terms to bug-mining README.
rjust Feb 18, 2018
12815b5
Some clarifications in README.
rjust Feb 18, 2018
d68a09e
Fewer jobs for Mockito.
rjust Feb 18, 2018
58a8d77
Split a batch of 10 Closure bugs that always time out on Travis into …
rjust Feb 18, 2018
80fed7e
Renamed promote script and update the documentation; still need to up…
rjust Feb 18, 2018
b423267
Updated the README.
rjust Feb 18, 2018
3b5e881
Fixed a typo in project module template.
rjust Mar 4, 2018
1a3f8cb
Merge branch 'merge-bug-mining-into-master' of https://github.com/tom…
rjust Mar 5, 2018
971eb69
In download issues script add new param into documentation and requir…
tomecho Mar 13, 2018
85b020a
In download issues script append org to uri unless its part of projec…
tomecho Mar 13, 2018
700b122
Updated README and added TODOs.
rjust Mar 15, 2018
088d589
Correct download issues script to require a org for github (through p…
tomecho Mar 16, 2018
773f3ed
git push Merge branch 'merge-bug-mining-into-master' of github.com:to…
tomecho Mar 16, 2018
d74a659
Merge branch 'merge-bug-mining-into-master' of https://github.com/tom…
rjust Mar 16, 2018
38c3221
Update readme and download issues script to be more obvious about dif…
tomecho Mar 17, 2018
5897288
Merge from master
tomecho Mar 17, 2018
bea3d50
Renamed and updated get-metadata script.
rjust Mar 18, 2018
c0db26c
Fixed minimize-patch script.
rjust Mar 18, 2018
8ebe758
Smaller change in README.
rjust Mar 18, 2018
675590f
Merge branch 'merge-bug-mining-into-master' of https://github.com/tom…
rjust Mar 18, 2018
b04a3b8
Fixed a typo in the main build file.
rjust Mar 19, 2018
6a2866d
Merge branch 'merge-bug-mining-into-master' of https://github.com/tom…
rjust Mar 19, 2018
7cc6dd8
Fleshing out bug mining README
Greg4cr Mar 20, 2018
2883494
Added more information on bug-mining README
ypzheng Mar 21, 2018
1fa8211
Fixed typos in formatter.
Mar 24, 2018
ac6c1f0
Added build-file-analyzer to lib, and updated gitignore.
Mar 24, 2018
9ca981e
Updated initialize-revision to call analyzer.
Mar 24, 2018
eb248b1
Updated initialize-revision to download dependencies.
Mar 24, 2018
fc699b9
Updated Formatter to handle special cases where test names passed in …
Mar 28, 2018
4af0584
Require tracker_id in merge-commit-db
tomecho Mar 29, 2018
7afbc18
Ignore any other special params on commit db when looking for revs
tomecho Mar 29, 2018
ef352d4
Updated template.build.xml to use analyzer produced test patterns.
Mar 29, 2018
03a6947
Updated README.
ypzheng Mar 29, 2018
20798c7
Merge branch 'merge-bug-mining-into-master' of https://github.com/tom…
Mar 29, 2018
3b15473
All new bugs entered will get tracker id
tomecho Mar 30, 2018
8a28449
Merge branch 'merge-bug-mining-into-master' of github.com:tomecho/def…
tomecho Mar 30, 2018
99b19be
Small change in Formatter and removed unneccessary files.
Mar 30, 2018
c85c541
Use OS-specific path separater to find build file.
Mar 30, 2018
0d3cdda
Changed project directory to relative path template.build.xml.
Mar 31, 2018
8a9fd7d
If patch test doesnt exist set size to 0
tomecho Apr 6, 2018
3a2d185
Revert "If patch test doesnt exist set size to 0"
tomecho Apr 6, 2018
a085d61
Revert "Revert "If patch test doesnt exist set size to 0""
tomecho Apr 6, 2018
d998509
Init variable to empty string if not set to a value
tomecho Apr 13, 2018
87e7318
Fix call to create_project in promot to db
tomecho Apr 13, 2018
d6e2d89
Revert "Ignore any other special params on commit db when looking for…
tomecho Apr 13, 2018
b690584
Revert changes made to merge commit-db they were incorrect
tomecho Apr 13, 2018
1c484cd
Fix missing variable declaration in DB.pm
tomecho Apr 13, 2018
f3fa052
Add tracker id at the rev list database
tomecho Apr 13, 2018
5f16ef5
Adding in tracker name but it isnt working for whatever reason
tomecho Apr 13, 2018
ac22e7c
Still wont find options for whatever reason
tomecho Apr 13, 2018
2fbb308
Using n is not permitted for arguments with getopts who would have gu…
tomecho Apr 13, 2018
5a964c4
Merge branch 'merge-bug-mining-into-master' of https://github.com/tom…
Apr 13, 2018
09e5ea8
Allow case-insensitive user input.
Apr 13, 2018
2680621
Modified README.
Apr 14, 2018
9512923
Reorganize test directories and add new test cases for analyzer.
Apr 14, 2018
9683cd5
Add one more test case.
Apr 14, 2018
5c9dcef
Update analyzer build file.
Apr 15, 2018
617d746
Add one more edge case, and refactored code.
Apr 15, 2018
d9cc988
Changed error message to print with debugger.
Apr 15, 2018
cde66a6
Add one more test case.
Apr 15, 2018
01a8b2c
Moved subtask helper method to util.
Apr 15, 2018
53eb339
Move method to util.
Apr 15, 2018
2e83377
Analyze src,test,src_output,and test_output directories.
Apr 15, 2018
91dc097
Update test cases to support new functions, and update analyzer.jar.
Apr 15, 2018
eabf023
Unrevert original changes (sorry done this a few times but i wasnt to…
tomecho Apr 15, 2018
6d2bfb4
Revert "Revert "Ignore any other special params on commit db when loo…
tomecho Apr 15, 2018
26ec99a
Merge branch 'merge-bug-mining-into-master' of github.com:tomecho/def…
tomecho Apr 15, 2018
d2c463a
Fix wrong target input and hot fix on getting src.test.dir.
Apr 15, 2018
e28c159
Update README and analyzer.jar.
Apr 15, 2018
8d98659
Merge branch 'merge-bug-mining-into-master' of https://github.com/tom…
Apr 15, 2018
cdb2481
Can supply src directory to the merge-commit-db script for projects w…
Greg4cr Jun 1, 2018
c447711
Merge branch 'merge-bug-mining-into-master' of https://github.com/tom…
rjust Oct 4, 2018
20cc487
Clarified a few bits and added a few TODOs.
jose Nov 14, 2018
1791a0b
Clarified 'project name' format.
jose Nov 20, 2018
a464440
Attempt to normalize documentation, options, and code.
jose Nov 21, 2018
1216851
Merge https://github.com/rjust/defects4j into merge-bug-mining-into-m…
rjust Nov 22, 2018
caff8fb
Pass over scripts that initialize revisions.
jose Nov 28, 2018
cd211cb
Removed invalid instruction.
jose Nov 28, 2018
2503ebf
Merge https://github.com/rjust/defects4j into merge-bug-mining-into-m…
rjust Nov 29, 2018
0831aeb
All bug-mining scripts are executable and don't require an explicit c…
rjust Nov 29, 2018
064c722
Merge branch 'merge-bug-mining-into-master' of https://github.com/tom…
rjust Nov 29, 2018
96430f3
Fixed broken merge.
rjust Nov 29, 2018
92d9204
Improved the bug-mining README.
rjust Nov 29, 2018
9fb5d4f
Restored meta data for Time.
rjust Nov 29, 2018
4197ad0
Removed a file that should not be under version control
rjust Nov 29, 2018
20d89a8
Merge https://github.com/rjust/defects4j into merge-bug-mining-into-m…
rjust Nov 29, 2018
3d66f63
Minor tweak in README.
rjust Nov 29, 2018
8cda82d
Moved build-analyzer utility program to another repository.
jose Nov 30, 2018
f9e6e06
Avoid keeping data of a failure bid.
jose Dec 2, 2018
032e959
Revert a previous commit and export variables.
jose Dec 2, 2018
9fae382
Added info messages.
jose Dec 2, 2018
cf64b0f
Fail if the build system is not ant or maven.
jose Dec 2, 2018
3733d29
Fixed variables.
jose Dec 2, 2018
c4d4233
Augmented the list of generic files that should be copied over.
jose Dec 2, 2018
8c2868e
Re-use existing function to copy files.
jose Dec 2, 2018
0764b00
Augmented list of revision specific files.
jose Dec 2, 2018
a4d8178
Copy over 'lib' directory.
jose Dec 3, 2018
ce7c02e
Copy over the repository directory.
jose Dec 3, 2018
63b81e7
Fixed regex to identify the directory name.
jose Dec 3, 2018
91a8d95
Update project_repos README file.
jose Dec 3, 2018
aaa0abe
Copy project submodule.
jose Dec 3, 2018
4e14af9
Collect issues urls.
jose Dec 3, 2018
9a94282
Populate 'commit-db' with issue-tracker ID and URL.
jose Dec 4, 2018
284ba84
Promote a commit-db with issue-tracker ids and issue urls.
jose Dec 4, 2018
5066716
Older commits first.
jose Dec 4, 2018
ee5c4d7
-r parameter is mandatory.
jose Dec 4, 2018
125d587
Attempt to simplify the step-by-step tutorial.
jose Dec 6, 2018
071130c
Fix.
jose Dec 6, 2018
01d5bda
Perform a couple sanity checks after minimizing a patch.
jose Dec 6, 2018
62cae78
Removed debug messages.
jose Dec 6, 2018
6011513
Override global constant, otherwise checkout command it is not able o…
jose Dec 7, 2018
49b7557
Copy over the 'relevant_tests' directory.
jose Dec 7, 2018
f4197bc
Added test cases for the bug-mining framework.
jose Dec 7, 2018
ae0ed83
Java-7 support.
jose Dec 7, 2018
d608832
${d4j.home}/framework/projects/ -> ${d4j.dir.projects}/
jose Dec 7, 2018
1da2264
Added test_bug_mining to travis configuration file.
jose Dec 7, 2018
3cf7c33
The bug-mining framework might require Apache Maven on the PATH to mi…
jose Dec 7, 2018
5177128
Attempt to debug Travis failure.
jose Dec 7, 2018
6a6493a
Added module List::Util to the list of required Perl modules as the d…
jose Dec 7, 2018
1ca2bd2
Relaxed assertions of trigger_tests and failing_tests.
jose Dec 7, 2018
7454029
Attempt to address the "Can't locate DBI.pm in @INC" issue.
jose Dec 7, 2018
6ca9b97
Deleted debug message.
jose Dec 7, 2018
a9581e6
Utility script get_modified_classes.pl requires diffstat to determine…
jose Dec 7, 2018
462de96
Inform bug-mining users that diffstat must be installed.
jose Dec 7, 2018
fa7b1d3
Several command-line options were not enabled. Some are still not use…
Greg4cr Dec 13, 2018
204ad9b
Extracted issues ids from the commit history.
jose Dec 11, 2018
6ec9346
Report the oldest bug report id. Commit c7a581e55fc988bd90fa4bb1b0ace…
jose Jan 16, 2019
64ed5e9
Fix: report issues ids and not pull requests ids.
jose Jan 16, 2019
50cc741
Use the official google archive URL.
jose Jan 16, 2019
ff3b9f2
Added subroutines to extract a bug report ID and a bug report URL.
jose Jan 16, 2019
fa6f3c6
Merge branch 'master' into merge-bug-mining-into-master
jose Jan 16, 2019
7a2e9d6
Merge branch 'merge-bug-mining-into-master' of github.com:tomecho/def…
jose Jan 16, 2019
663fbac
Fixed Chart commit-db file: all rows should have commas, even if no I…
jose Jan 17, 2019
4631945
Merge branch 'issues_ids_urls' into merge-bug-mining-into-master
jose Jan 17, 2019
7e50aa6
Re-use existing subroutines to extract a bug report id/url.
jose Jan 17, 2019
cc5113a
Fixed commit-db path.
jose Jan 17, 2019
4fba9a8
Removed unused use.
jose Jan 18, 2019
a8e4e70
Merge branch 'master' into merge-bug-mining-into-master
jose Jan 18, 2019
dc44e00
Updated version number.
rjust Jan 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ major/
framework/test/*.log
framework/lib/test_generation
framework/lib/build_systems
framework/lib/analyzer.jar
work/
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ provides the following scripts:
| [run_evosuite](http://people.cs.umass.edu/~rjust/defects4j/html_doc/run_evosuite.html) | Generate test suites using EvoSuite |
| [run_randoop](http://people.cs.umass.edu/~rjust/defects4j/html_doc/run_randoop.html) | Generate test suites using Randoop |

Mining and contributing additional bugs to Defects4J
================
The bug-mining [README](framework/bug-mining/README.md) details the bug-mining process.


Additional resources
================

Expand Down
345 changes: 345 additions & 0 deletions framework/bug-mining/README.md

Large diffs are not rendered by default.

353 changes: 353 additions & 0 deletions framework/bug-mining/analyze-project.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,353 @@
#!/usr/bin/env perl
#
#-------------------------------------------------------------------------------
# Copyright (c) 2014-2018 René Just, Darioush Jalali, and Defects4J contributors.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#-------------------------------------------------------------------------------

=pod

=head1 NAME

analyze-project.pl -- Determine all suitable candidates listed in the commit-db.

=head1 SYNOPSIS

analyze-project.pl -p project_id -w work_dir -g tracker_name -t tracker_project_id [-b bug_id]

=head1 OPTIONS

=over 4

=item B<-p C<project_id>>

The id of the project for which the version pairs are analyzed.

=item B<-w C<work_dir>>

The working directory used for the bug-mining process.

=item B<-g C<tracker_name>>

The source control tracker name, e.g., jira, github, google, or sourceforge.

=item B<-t C<tracker_project_id>>

The name used on the issue tracker to identify the project. Note that this might
not be the same as the Defects4j project name / id, for instance, for the
commons-lang project is LANG.

=item B<-b C<bug_id>>

Only analyze this bug id. The bug_id has to follow the format B<(\d+)(:(\d+))?>.
Per default all bug ids, listed in the commit-db, are considered.

=back

=head1 DESCRIPTION

Runs the following worflow for all candidate bugs in the project's C<commit-db>,
or (if -b is specified) for a subset of candidates:

=over 4

=item 1) Verify that src diff (between pre-fix and post-fix) is not empty.

=item 3) Checkout fixed revision.

=item 4) Compile src and test.

=item 5) Run tests and log failing tests to F<C<PROJECTS_DIR>/<PID>/failing_tests>.

=item 6) Exclude failing tests, recompile and rerun. This is repeated until
there are no more failing tests in F<$TEST_RUNS> consecutive
executions. (Maximum limit of looping in this phase is specified by
F<$MAX_TEST_RUNS>).

=item 7) Checkout fixed version.

=item 8) Apply src patch (fixed -> buggy).

=item 9) Compile src and test.

=back

The result for each individual step is stored in F<C<work_dir>/$TAB_REV_PAIRS>.
For each steps the output table contains a column, indicating the result of the
the step or '-' if the step was not applicable.

=cut
use warnings;
use strict;
use File::Basename;
use Cwd qw(abs_path);
use Getopt::Std;
use Pod::Usage;
use Carp qw(confess);

use lib (dirname(abs_path(__FILE__)) . "/../core/");
use Constants;
use Project;
use DB;
use Utils;

my %cmd_opts;
getopts('p:w:g:t:b:', \%cmd_opts) or pod2usage(1);

pod2usage(1) unless defined $cmd_opts{p} and defined $cmd_opts{w}
and defined $cmd_opts{g} and defined $cmd_opts{t};

my $PID = $cmd_opts{p};
my $BID = $cmd_opts{b};
my $WORK_DIR = abs_path($cmd_opts{w});
my $TRACKER_ID = $cmd_opts{t};
my $TRACKER_NAME = $cmd_opts{g};

# Check format of target version id
if (defined $BID) {
$BID =~ /^(\d+)(:(\d+))?$/ or die "Wrong version id format ((\\d+)(:(\\d+))?): $BID!";
}

# Add script and core directory to @INC
unshift(@INC, "$WORK_DIR/framework/core");

# Override global constants
$REPO_DIR = "$WORK_DIR/project_repos";
$PROJECTS_DIR = "$WORK_DIR/framework/projects";

# Set the projects and repository directories to the current working directory
my $PATCHES_DIR = "$PROJECTS_DIR/$PID/patches";
my $FAILING_DIR = "$PROJECTS_DIR/$PID/failing_tests";

# TODO make output dir more flexible; maybe organize the csv-based db differently
my $db_dir = $WORK_DIR;

# Number of successful test runs in a row required
my $TEST_RUNS = 2;
# Number of maximum test runs (give up point)
my $MAX_TEST_RUNS = 10;

# Temporary directory
my $TMP_DIR = Utils::get_tmp_dir();
system("mkdir -p $TMP_DIR");

# Set up project
my $project = Project::create_project($PID);
$project->{prog_root} = $TMP_DIR;

# Get database handle for results
my $dbh = DB::get_db_handle($TAB_REV_PAIRS, $db_dir);
my @COLS = DB::get_tab_columns($TAB_REV_PAIRS) or die;

# Figure out which IDs to run script for
my @ids = $project->get_version_ids();
if (defined $BID) {
if ($BID =~ /(\d+):(\d+)/) {
@ids = grep { ($1 <= $_) && ($_ <= $2) } @ids;
} else {
# single vid
@ids = grep { ($BID == $_) } @ids;
}
}

my $sth = $dbh->prepare("SELECT * FROM $TAB_REV_PAIRS WHERE $PROJECT=? AND $ID=?") or die $dbh->errstr;
foreach my $bid (@ids) {
printf ("%4d: $project->{prog_name}\n", $bid);

# Skip existing entries
$sth->execute($PID, $bid);
if ($sth->rows !=0) {
printf(" -> Skipping (existing entry in $TAB_REV_PAIRS)\n");
next;
}

my %data;
$data{$PROJECT} = $PID;
$data{$ID} = $bid;
$data{$ISSUE_TRACKER_NAME} = $TRACKER_NAME;
$data{$ISSUE_TRACKER_ID} = $TRACKER_ID;

_check_diff($project, $bid, \%data) and
_check_t2v2($project, $bid, \%data) and
_check_t2v1($project, $bid, \%data) or next;

# Add data set to result file
_add_row(\%data);
}
$dbh->disconnect();
system("rm -rf $TMP_DIR");

#
# Check size of src diff, which is created by initialize-revisions.pl script,
# for a given candidate bug (bid).
#
# Returns 1 on success, 0 otherwise
#
sub _check_diff {
my ($project, $bid, $data) = @_;

# Determine patch size for src and test patches (rev2 -> rev1)
my $patch_test = "$PATCHES_DIR/$bid.test.patch";
my $patch_src = "$PATCHES_DIR/$bid.src.patch";

if (!(-e $patch_test) || (-z $patch_test)) {
$data->{$DIFF_TEST} = 0;
} else {
my $diff = _read_file($patch_test);
die unless defined $diff;
$data->{$DIFF_TEST} = scalar(split("\n", $diff));
}

if (-z $patch_src) {
$data->{$DIFF_SRC} = 0;
return 0;
} else {
my $diff = _read_file($patch_src);
die unless defined $diff;
$data->{$DIFF_SRC} = scalar(split("\n", $diff)) or return 0;
}

return 1;
}

#
# Check whether v2 and t2 can be compiled and export failing tests.
#
# Returns 1 on success, 0 otherwise
#
sub _check_t2v2 {
my ($project, $bid, $data) = @_;

# Lookup revision ids
my $v1 = $project->lookup("${bid}b");
my $v2 = $project->lookup("${bid}f");

# Clean previous results
`>$FAILING_DIR/$v2` if -e "$FAILING_DIR/$v2";

# Checkout v2
$project->checkout_vid("${bid}f", $TMP_DIR, 1) == 1 or die;

# Compile v2 ant t2
my $ret = $project->compile();
_add_bool_result($data, $COMP_V2, $ret) or return 0;
$ret = $project->compile_tests();
_add_bool_result($data, $COMP_T2V2, $ret) or return 0;

my $successful_runs = 0;
my $run = 1;
while ($successful_runs < $TEST_RUNS && $run <= $MAX_TEST_RUNS) {
# Automatically fix broken tests and recompile
$project->fix_tests("${bid}f");
$project->compile_tests() or die;

# Run t2 and get number of failing tests
my $file = "$project->{prog_root}/v2.fail"; `>$file`;
$project->run_tests($file) or die;
# Get number of failing tests
my $list = Utils::get_failing_tests($file);
my $fail = scalar(@{$list->{"classes"}}) + scalar(@{$list->{"methods"}});

if ($run == 1) {
$data->{$FAIL_T2V2} = $fail;
} else {
$data->{$FAIL_T2V2} += $fail;
}

++$successful_runs;

# Append to log if there were (new) failing tests
unless ($fail == 0) {
open(OUT, ">>$FAILING_DIR/$v2") or die "Cannot write failing tests: $!";
print OUT "## $project->{prog_name}: $v2 ##\n";
close OUT;
system("cat $file >> $FAILING_DIR/$v2");
$successful_runs = 0;
}
++$run;
}
return 1;
}

#
# Check whether t2 and v1 can be compiled
#
sub _check_t2v1 {
my ($project, $bid, $data) = @_;

# Lookup revision ids
my $v1 = $project->lookup("${bid}b");
my $v2 = $project->lookup("${bid}f");

# Checkout v1
$project->checkout_vid("${bid}b", $TMP_DIR, 1) == 1 or die;

# Compile v1 and t2v1
my $ret = $project->compile();
_add_bool_result($data, $COMP_V1, $ret) or return;
$ret = $project->compile_tests();
_add_bool_result($data, $COMP_T2V1, $ret);
}

#
# Read a file line by line and return an array with all lines.
#
sub _read_file {
my $fn = shift;
open(FH, "<$fn") or confess "Could not open file: $!";
my @lines = <FH>;
close(FH);
return join('', @lines);
}

#
# Insert boolean success into hash
#
sub _add_bool_result {
my ($data, $key, $success) = @_;
$data->{$key} = $success;
}

#
# Add a row to the database table
#
sub _add_row {
my $data = shift;

my @tmp;
foreach (@COLS) {
push (@tmp, $dbh->quote((defined $data->{$_} ? $data->{$_} : "-")));
}

my $row = join(",", @tmp);
$dbh->do("INSERT INTO $TAB_REV_PAIRS VALUES ($row)");
}

=pod

=head1 SEE ALSO

Previous step in workflow: Manually verify that all test failures
(failing_tests) are valid and not spurious, broken, random, or due to classpath
issues.

Next step in workflow: F<get-trigger.pl>.

=cut
Loading