Skip to content

Conversation

jkhaliqi
Copy link
Contributor

@jkhaliqi jkhaliqi commented Mar 6, 2025

Cleaned up ECJJava15IRTest.java by refactoring the tests to be parameterized to not rely on method name for running the tests. Also removed the getTestName from IRTests so the tests do not rely on that method to get the name of the test it should run. With this we pass in the name and tests can now be parameterized as well instead of relying on naming tests differently

Copy link

github-actions bot commented Mar 6, 2025

Test Results

  827 files  ±  0    827 suites  ±0   4h 20m 54s ⏱️ - 21m 45s
  866 tests +101    849 ✅ +101   17 💤 ±0  0 ❌ ±0 
5 239 runs  ±  0  5 118 ✅ ±  0  121 💤 ±0  0 ❌ ±0 

Results for commit e04fcf9. ± Comparison against base commit 4722084.

This pull request removes 59 and adds 160 tests. Note that renamed tests count towards both.
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testAnnotations()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testAnonGeneNullarySimple()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testAnonymousGenerics()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testBasicsGenerics()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testCocovariant()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testCustomGenericsAndFields()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testEnumSwitch()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testExplicitBoxingTest()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testGenericArrays()
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ testGenericMemberClasses()
…
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [10] java15IRTestName=GenericMemberClasses
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [11] java15IRTestName=GenericSuperSink
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [12] java15IRTestName=MoreOverriddenGenerics
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [13] java15IRTestName=NotSoSimpleEnums
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [14] java15IRTestName=OverridesOnePointFour
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [15] java15IRTestName=SimpleEnums
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [16] java15IRTestName=SimpleEnums2
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [17] java15IRTestName=TypeInferencePrimAndStringOp
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [18] java15IRTestName=Varargs
com.ibm.wala.cast.java.test.ECJJava15IRTest ‑ [19] java15IRTestName=VarargsCovariant
…

♻️ This comment has been updated with latest results.

@jkhaliqi
Copy link
Contributor Author

jkhaliqi commented Mar 6, 2025

@msridhar @juliandolby Hey whenever you get a chance could I get review on this, thank you!

@msridhar
Copy link
Member

msridhar commented Mar 6, 2025

@jkhaliqi I love it! Do you have time to take this further? This is the key function that pulls out the name of the currently-running test:

protected String getTestName() {
StackTraceElement stack[] = new Throwable().getStackTrace();
for (int i = 0; i <= stack.length; i++) {
if (stack[i].getMethodName().startsWith("test")) {
return stack[i].getMethodName();
}
}
throw new Error("test method not found");
}

I'd love it if we could push this cleanup further so that the function above could just be deleted and everywhere we rely on it we instead use parameterized tests. I think it would involve a few more changes similar to what you've already done and (hopefully!) deleting a bunch of code. What do you think?

@jkhaliqi
Copy link
Contributor Author

jkhaliqi commented Mar 6, 2025

Hey sounds good, and thank you! I'll give that a try and see how far I get

@jkhaliqi jkhaliqi force-pushed the parameterize-IR branch 5 times, most recently from d1483aa to ffbd13b Compare March 7, 2025 00:58
@msridhar
Copy link
Member

msridhar commented Mar 7, 2025

@jkhaliqi is this ready for review?

@jkhaliqi
Copy link
Contributor Author

jkhaliqi commented Mar 7, 2025

@msridhar Yup, I believe this is ready for review, whenever you get a chance, thank you!

@jkhaliqi jkhaliqi changed the title refactored ECJJava15IRTests to be parameterized refactor: remove getTestName from IRTests.java so tests do noot rely on method name Mar 7, 2025
@jkhaliqi jkhaliqi changed the title refactor: remove getTestName from IRTests.java so tests do noot rely on method name refactor: remove getTestName from IRTests.java so tests do not rely on method name Mar 7, 2025
@jkhaliqi
Copy link
Contributor Author

jkhaliqi commented Mar 7, 2025

I just changed the JavaIRTests to be alphabetical as well for parametrized tests, but all should be good now!

Copy link
Member

@msridhar msridhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! A couple of comments particularly on JavaIRTests

true,
null);
}
static List<? extends IRAssertion> caForInterfaceTest1 =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This naming scheme caForXXX is confusing. What does ca mean? Can we use something more descriptive?

Copy link
Contributor Author

@jkhaliqi jkhaliqi Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't exactly sure what ca also meant I got this variable name from the fourth parameter inside of runTests. But i'm assuming it has something to do with the callGraph and just changed it to be callAssertionsForXXX. Let me know if theres a better name.

}

@Test
public void testArrayLiteral2() throws IllegalArgumentException, CancelException, IOException {
public void testTwoClasses() throws IllegalArgumentException, CancelException, IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the remaining tests still here and not just run via the parameterized tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the remaining tests call runTests and store its output in a variable and then do other stuff with it so I just left those alone.

@msridhar
Copy link
Member

@jkhaliqi can you just add commits to your branch from now on instead of force pushing? That will make it easier to see what is changing. I will squash the commits before merging.

@jkhaliqi
Copy link
Contributor Author

@msridhar Sounds good, sorry about that!

Copy link
Member

@msridhar msridhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again so much for this cleanup! One more comment / question

Comment on lines 485 to 491
runTest(
singleTestSrc("InnerClassA"),
rtJar,
simpleTestEntryPoint("InnerClassA"),
new ArrayList<>(),
true,
null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many call sites now where we pass exactly these arguments, except that the test name is different. Could we possibly add a new wrapper method for runTest that takes a single String argument and then calls runTest appropriately, and then replace all these other calls with a call to the wrapper method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in the wrapper, thank you!

msridhar
msridhar previously approved these changes Mar 13, 2025
@msridhar
Copy link
Member

Thanks again for the contribution!

@msridhar msridhar requested a review from liblit March 13, 2025 01:35
@msridhar msridhar enabled auto-merge (squash) March 13, 2025 01:35
@msridhar
Copy link
Member

@liblit I think you will need to approve again before this can land

Copy link
Contributor

@liblit liblit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to this bot comment, this change results in a net increase of 101 tests. Is that expected?

auto-merge was automatically disabled March 13, 2025 18:21

Head branch was pushed to by a user without write access

@jkhaliqi
Copy link
Contributor Author

@liblit I believe so, is there a way I can double check all the test cases the bot only shows a couple before showing the ...

@msridhar
Copy link
Member

@liblit I believe so, is there a way I can double check all the test cases the bot only shows a couple before showing the ...

Yeah, this is pretty hard to check based on the bot comment which cuts off the output. Any ideas @liblit? I can see various artifacts related to the executed tests at the bottom of the page for the action run but not clear how to get the full differences from that.

@liblit
Copy link
Contributor

liblit commented Mar 17, 2025

You could run the tests on your local machine. Test before and after your proposed changes. Presumably each of those will create some kind of artifact you can compare without truncation.

@msridhar
Copy link
Member

You could run the tests on your local machine. Test before and after your proposed changes. Presumably each of those will create some kind of artifact you can compare without truncation.

Sure, I guess I was wondering if there's an easy way to run whatever code generates the comments on the pull requests, though I guess one could just run diff on the relevant files.

@msridhar
Copy link
Member

In 0db3fc9 I tried bumping up the limit on how many test changes are listed in the comment, using the test_changes_limit setting, but it didn't seem to work 😐

@jkhaliqi
Copy link
Contributor Author

@liblit Can you explain more on the test and artifact comparison I wasn't able to follow or find the artifacts created after running the test. But I did just run and compare and everything is the same as far as these tests with first number being current change and second one before changes. There's only an increase in one for the tests because the @parameterized part will run but everything else ran the same...
java15irtest -> 22 -> 21
java17 -> 7 -> 6
testcomments-> same
Issue666Test.java -> same
Issue667Test -> same
jlextest -> same
javairtest -> 37-> 37
syncduplicator -> same

@msridhar msridhar enabled auto-merge (squash) March 22, 2025 00:08
@msridhar
Copy link
Member

Thanks again for the contribution @jkhaliqi!

@msridhar msridhar merged commit 0080591 into wala:master Mar 22, 2025
10 checks passed
apple5775 pushed a commit to apple5775/WALA that referenced this pull request Apr 2, 2025
…n method name (wala#1485)

Cleaned up `ECJJava15IRTest.java` by refactoring the tests to be
parameterized to not rely on method name for running the tests. Also
removed the `getTestName` from `IRTests` so the tests do not rely on
that method to get the name of the test it should run. With this we pass
in the name and tests can now be parameterized as well instead of
relying on naming tests differently

---------

Co-authored-by: Manu Sridharan <msridhar@gmail.com>
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

Successfully merging this pull request may close these issues.

3 participants