defects4j icon indicating copy to clipboard operation
defects4j copied to clipboard

Problem with testing patches for Lang 29

Open h4iku opened this issue 2 years ago • 2 comments

There is a problem with Lang 29 where if you compile and test the buggy checkout, patching it next won't change the test result.

Steps to reproduce

  1. Checkout the buggy version of Lang 29:
    $ defects4j/framework/bin/defects4j checkout -p Lang -v 29b -w tmp/lang29-buggy
    
  2. Compile and run the tests:
    $ defects4j/framework/bin/defects4j compile -w tmp/lang29-buggy
    $ defects4j/framework/bin/defects4j test -w tmp/lang29-buggy
    Failing tests: 1
        - org.apache.commons.lang3.SystemUtilsTest::testJavaVersionAsInt
    
  3. Head to the problematic source file at tmp/lang29-buggy/src/main/java/org/apache/commons/lang3/SystemUtils.java, line 1672 and fix the issue:
    -    static float toJavaVersionInt(String version) {
    +    static int toJavaVersionInt(String version) {
    
  4. Compile and test (test will fail again):
    $ defects4j/framework/bin/defects4j compile -w tmp/lang29-buggy
    $ defects4j/framework/bin/defects4j test -w tmp/lang29-buggy
    Failing tests: 1
        - org.apache.commons.lang3.SystemUtilsTest::testJavaVersionAsInt
    

If you manually delete the compiled test class from the target directory at tmp/lang29-buggy/target/test-classes/org/apache/commons/lang3/SystemUtilsTest.class, the test will pass:

$ defects4j/framework/bin/defects4j test -w tmp/lang29-buggy
Failing tests: 0

h4iku avatar Jul 09 '22 16:07 h4iku

Thanks for reporting this, @h4iku.

Can you please let us know what your OS and system environment you are using?

rjust avatar Oct 27 '22 00:10 rjust

I first encountered this issue on a WSL Ubuntu 20.04 installation on Windows 10. Java version was 1.8.0_332 Temurin installed using SDKMAN. Now the same system is updated to Ubuntu 22.04 with Java 1.8.0_345 Temurin, and the problem is still reproducible. Maven is 3.8.6.

I checked the issue on the latest Manjaro Linux update and Pop!_OS 22.04 with the same Java 8 version, and it still happened. There is no separate Ant or Maven installation on these systems.

I've seen this behavior on other random Java projects. I guess that's why people obsessively clean compile their projects.

h4iku avatar Oct 27 '22 18:10 h4iku