-
Notifications
You must be signed in to change notification settings - Fork 16
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
Compile and overwrite test #175
Conversation
Where SourceTestClassWrapper is abstract, and do all ahrd work. The TestingDummyHelper jsut sets pkg, classname and class body
CliTest.java and CompileUploadCliTest are now extending AbstractAgentNeedingTest.java and so shoudl have no shared duplicated code. CompileUploadCliTest is now partially similar to CliTest, but is using ModifiableDummyTestingHelper instead of TestingDummyHelper
Oh it did usefull thinhg! It removed all nasty static imports!
I would suggest moving the "utility" classes to a different package in order to differentiate them from the actual org.jrd.backend.data test classes ( |
not much agaist. What is the "AbstractAgentNeedingTest" then :)
…--
Mgr. Jiri Vanek
***@***.***
---------- Původní e-mail ----------
Od: Prokop Tunel ***@***.***>
Komu: pmikova/java-runtime-decompiler ***@***.***
github.com>
Datum: 8. 10. 2021 10:23:18
Předmět: Re: [pmikova/java-runtime-decompiler] Compile and overwrite test (#
175)
"
I would suggest moving the "utility" classes to a different package in order
to differentiate them from the actual org.jrd.backend.data test classes (
CliTest, CompileUploadCliTest, but also ArchiveManagerOptionsTest).
Thoughts?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
(#175 (comment))
, or unsubscribe
(https://github.com/notifications/unsubscribe-auth/AAWFCS2PCEUSINNVNHB25M3UF2S67ANCNFSM5FRQV6GQ)
.
Triage notifications on the go with GitHub Mobile for iOS
(https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675)
or Android
(https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub)
.
"
|
had to extract few constants on the fly
Tests will fail until #111 is implemented. EDIT: it is too late for me to understand why the CI test passed. No idea. Dumbfounded. Perplexed. Astonished. Too many emotions. EDIT EDIT: Oh yeah, in |
The Windows test has been running for 10 minutes, that isn't good. Mainly because I will have to be the one fixing it. |
Right you are. I will add some assume.
yah:(
Very interesting! That was also my impression, that the plugin manager shoudl work with fresh install. And I have correct setup :) |
I have not done a in-depth review yet. When I do in the next few days, I'll comment on it. Please don't merge this PR until then :D
I was talking about the |
…cli and args For Prokop: fields - class instance variales - are here to keep state of the object. Local variables, are here to see state of method. All this allows you better separation of member methods, utility methods and future exnesions without massive refactoings
…ime-decompiler into comileAndOverwriteTest
.github/workflows/maven.yaml
Outdated
@@ -76,4 +76,4 @@ jobs: | |||
- name: Test Cli | |||
run: | | |||
cd jrd | |||
mvn --batch-mode test -Dtest=CliTest -DfailIfNoTests=false | |||
mvn --batch-mode test -Dtest=*CliTest -DfailIfNoTests=false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why there is this condition at all? Test all!
Also the -DfailIfNoTests=false seems wrong. lets fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ook. thanx
I see your 20 minute timeout still didn't help on Windows. Since all tests finish in under a minute on Ubuntu, this is a more serious issue than Windows just being slightly slower (which was the case prior to this PR - Windows build took about 1.5x the total time of the Ubuntu one). |
7e3e241
to
fdbdcf5
Compare
yy. remopved |
runtime-decompiler/src/test/java/org/jrd/backend/data/AbstractSourceTestClass.java
Show resolved
Hide resolved
runtime-decompiler/src/test/java/org/jrd/backend/data/AbstractSourceTestClass.java
Show resolved
Hide resolved
runtime-decompiler/src/test/java/org/jrd/backend/data/CliTest.java
Outdated
Show resolved
Hide resolved
void testBytes() throws Exception { | ||
testBytes(dummy.getPid()); | ||
testBytes(dummy.getClasspath()); | ||
} | ||
|
||
void testBase64Bytes(String pucComponent) throws Exception { | ||
args = new String[]{BASE64, pucComponent, dummy.getClassRegex()}; | ||
cli = new Cli(args, model); | ||
|
||
cli.consumeCli(); | ||
|
||
byte[] base64Bytes = streams.getOut().trim().getBytes(StandardCharsets.UTF_8); | ||
byte[] fileContents = Files.readAllBytes(Path.of(dummy.getDotClassPath())); | ||
byte[] encoded = Base64.getEncoder().encode(fileContents); | ||
|
||
assertArrayEquals(encoded, base64Bytes); | ||
} | ||
|
||
@Test | ||
void testBase64Bytes() throws Exception { | ||
testBase64Bytes(dummy.getPid()); | ||
testBase64Bytes(dummy.getClasspath()); | ||
} | ||
|
||
void testBytesAndBase64BytesEqual(String pucComponent) throws Exception { | ||
args = new String[]{BYTES, pucComponent, dummy.getClassRegex()}; | ||
cli = new Cli(args, model); | ||
|
||
cli.consumeCli(); | ||
byte[] bytes = streams.getOutBytes(); | ||
|
||
args = new String[]{BASE64, pucComponent, dummy.getClassRegex()}; | ||
cli = new Cli(args, model); | ||
|
||
cli.consumeCli(); | ||
String base64 = streams.getOut().trim(); | ||
byte[] decoded = Base64.getDecoder().decode(base64); | ||
|
||
assertArrayEquals(bytes, decoded); | ||
} | ||
|
||
@Test | ||
void testBytesAndBase64BytesEqual() throws Exception { | ||
testBytesAndBase64BytesEqual(dummy.getPid()); | ||
testBytesAndBase64BytesEqual(dummy.getClasspath()); | ||
} | ||
|
||
|
||
void testDecompileJavap(String pucComponent, String option) throws Exception { | ||
args = new String[]{DECOMPILE, pucComponent, "javap" + option, dummy.getClassRegex()}; | ||
cli = new Cli(args, model); | ||
|
||
cli.consumeCli(); | ||
String jrdDisassembled = streams.getOut(); | ||
String javapDisassembled = dummy.executeJavaP(option); | ||
|
||
// JRD javap has additional debug comment lines + header is different | ||
assertEqualsWithTolerance(jrdDisassembled, javapDisassembled, 0.8); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"", "-v"}) | ||
void testDecompileJavap(String option) throws Exception { | ||
testDecompileJavap(dummy.getPid(), option); | ||
testDecompileJavap(dummy.getClasspath(), option); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be and explanatory comment of why these tests are duplicated from the normal CliTest here: They support the later tests where bytes and javap functionality is needed, but not the tested subject.
@@ -144,14 +144,15 @@ private static int min3(int a, int b, int c) { | |||
} | |||
} | |||
|
|||
public static class StreamWrappers { | |||
|
|||
public static class JunitStderrOutThief { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand this renaming.
* Although the class definition was transforemd, in OpenJDK HotSpot | ||
* this implementation of dummy do not request the new definition, | ||
* adn continues to spit out its jitted output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. So it's basically the exact opposite of what we originally expected to happen: source code changes (which we expected not to withstand multiple cli calls), but output doesn't change (which we expected to change).
} | ||
} | ||
|
||
public static String readBinaryAsString(FileInputStream input, String charBase, CodingErrorAction action) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused parameter action
.
@@ -262,13 +268,28 @@ private void overwrite() throws Exception { | |||
} | |||
} | |||
|
|||
@SuppressFBWarnings(value = "OS_OPEN_STREAM", justification = "The stream is clsoed as conditionally as is created") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably could be cheesed by having the condition as a final boolean
variable. Probably.
see #182 Please fix in a separate PR. |
bc5fcdb
to
5d6e13e
Compare
5d6e13e
to
ff36371
Compare
Nah. :) |
60ded2b
to
0500b20
Compare
yah!
…--
Mgr. Jiri Vanek
***@***.***
---------- Původní e-mail ----------
Od: Prokop Tunel ***@***.***>
Komu: pmikova/java-runtime-decompiler ***@***.***
github.com>
Datum: 14. 10. 2021 22:51:56
Předmět: Re: [pmikova/java-runtime-decompiler] Compile and overwrite test (#
175)
"
"
Please fix in a separate PR.
"
Nah. :)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
(#175 (comment))
, or unsubscribe
(https://github.com/notifications/unsubscribe-auth/AAWFCS6H2QCNJYEWHP7GY4TUG47GNANCNFSM5FRQV6GQ)
.
Triage notifications on the go with GitHub Mobile for iOS
(https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675)
or Android
(https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub)
.
"
|
0500b20
to
17459ed
Compare
… issues Which is my only guess for why "javap -v" was stuck on loop forever. Stdout & stderr are now read in a loop rather than at once, and also their reading occurs at least once before the process is waitedFor().
The switch has to be in quotes, because Powershell, the default runner on windows-latest, interprets the dot in the property name as... some sort of keyword.
Instead of using some word-boundary using regex to match the plugin, we can skip the whole CLI and temp file ordeal by using the plugin manager.
17459ed
to
036a98b
Compare
No description provided.