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

how to use kanonizo with defeccts4j . please provide detailed answer #4

Open
mudasirhw opened this issue Jan 8, 2020 · 2 comments
Open

Comments

@mudasirhw
Copy link

No description provided.

@djpaterson
Copy link
Collaborator

Hi @mudasirhw

The Kanonizo tool is designed to be used with any Java program, not just with Defects4J - however, i have used the tool with Defects4J for a couple of published research papers (see #6)

Firstly, check out the project using Defects4J
defects4j checkout -p Chart -v 1b -w /tmp/Chart-1-b

Compile the project using Defects4J
cd /tmp/Chart-1-b && defects4j compile

Find the location of the source directory
SRC_DIR=$(defects4j export -p dir.bin.classes)

Find the location of the compiled test directory (note that default Defects4J implementation does not support this but my fork of the repo github.com/djpaterson/defects4j does allow this automatically
TEST_DIR=$(defects4j export -p dir.bin.tests)

Ensure that both JUnit and Kanonizo Jar are on your classpath
CP=$PATH_TO_JUNIT:$PATH_TO_KANONIZO

Get the path required for compilation from Defects4J (this is used by Kanonizo to load classes)
BUILD_CP=$(defects4j export -p cp.compile

Run Kanonizo:
java -cp $cp:$BUILD_CP org.kanonizo.Main -s $SRC_DIR -t $TEST_DIR -a <your-algorithm-choice -Dlog_dir=<DESIRED_OUTPUT_DIRECTORY> -Dlog_filename=<DESIRED_FILENAME>

If you need code coverage for your algorithm, add -Dinstrumenter=Scytheto the command line

The resulting ordering will be created as <YOUR_OUTPUT_DIRECTORY>/ordering/<YOUR_DESIRED_FILENAME>.csv - you can again use the information from defects4j to work out the location of the "trigger tests"

trigger_tests=$(defects4j export -p tests.trigger)
for test in $trigger_tests; do
  # turn test into Kanonizo format
 test=$(echo $test | perl -p -e "s/(.*)::(.*)/\2(\1)/g")
 # Extract index of trigger test from file
 index_of_failing_test=$(grep -n $test <YOUR_ORDERING_FILE> | cut -d':' -f1)
 echo "$test,$index_of_failing_test" >> results.csv
done

This will create a file containing the index of all of the trigger tests from the version in question.

Let me know if you have further questions.
Thanks,
Dave

@mudasirhw
Copy link
Author

Hi Dave, i do not know how should i reoreder the execution of test cases based on my algorithm. i have no idea of intrumentation. i am also not ableto comprehend how the techniques implemented by you reorder the test cases. Does it require me indepth knowledhe of java. i am stuck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants