Skip to content

Commit

Permalink
Exclude system, add jcommander support
Browse files Browse the repository at this point in the history
  • Loading branch information
776styjsu committed Oct 10, 2024
1 parent 02a2016 commit 8cd0a63
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 23 deletions.
Binary file added agent/replacecall/lib/jcommander-1.35.jar
Binary file not shown.
1 change: 1 addition & 0 deletions agent/replacecall/replacecall.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ configurations {
implementation.extendsFrom(plumelib)
}
dependencies {
compileOnly files('lib/jcommander-1.35.jar')
testImplementation 'junit:junit:4.+'
testImplementation 'org.hamcrest:hamcrest-all:1.3'
}
Expand Down
27 changes: 15 additions & 12 deletions agent/replacecall/src/main/java/randoop/SystemExitCalledError.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
* @see randoop.mock.java.lang.System
*/
public class SystemExitCalledError extends Error {

/** Status value for System.exit() call */
public final int status;

public SystemExitCalledError(int status) {
super(String.format("Call to System exit(%d) detected; terminating execution", status));
this.status = status;
// If there are any java.awt windows active java runtime will deadlock.
for (java.awt.Window w : java.awt.Window.getWindows()) {
w.dispose();
}
}

// /* Do not replace {@code System#exit(int)}, for running Major mutation tests with replacement */
//
// /** Status value for System.exit() call */
// public final int status;
//
// public SystemExitCalledError(int status) {
// super(String.format("Call to System exit(%d) detected; terminating execution", status));
// this.status = status;
// // If there are any java.awt windows active java runtime will deadlock.
// for (java.awt.Window w : java.awt.Window.getWindows()) {
// w.dispose();
// }
// }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package randoop.grt_mock.com.beust.jcommander.internal;

import com.beust.jcommander.internal.Console;

/**
* Do not wait for user input.
*/
public class DefaultConsole {
public static char[] readPassword(Console instance, boolean echoInput) {
return new char[0];
}
}
25 changes: 14 additions & 11 deletions agent/replacecall/src/main/java/randoop/mock/java/lang/System.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
@SuppressWarnings("JavaLangClash")
public class System {

/**
* Default mock for {@code System.exit(status)}. Throws an exception to allow Randoop to generate
* tests that acknowledge that exit occurs.
*
* @param status the exit status
* @throws SystemExitCalledError with the status
*/
@SuppressWarnings("DoNotCallSuggester")
public static void exit(int status) {
throw new SystemExitCalledError(status);
}
// /* Do not replace {@code System#exit(int)}, for running Major mutation tests with replacement */
//
// /**
// * Default mock for {@code System.exit(status)}. Throws an exception to allow Randoop to generate
// * tests that acknowledge that exit occurs.
// *
// * @param status the exit status
// * @throws SystemExitCalledError with the status
// */
// @SuppressWarnings("DoNotCallSuggester")
// public static void exit(int status) {
// throw new SystemExitCalledError(status);
// }

}

0 comments on commit 8cd0a63

Please sign in to comment.