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

Part of #3928 [Testing Examples] Add First Class Python Support #4166

Merged
merged 24 commits into from
Jan 7, 2025

Conversation

himanshumahajan138
Copy link
Contributor

@himanshumahajan138 himanshumahajan138 commented Dec 19, 2024

Pull Request

Adds First Class Python Support [Testing Examples]
Part of #3928

Description

Testing Examples for Python 1-test-suite, 2-test-deps, 3-integration-suite Examples

Related Issues

Checklist

  • 1-test-suite
  • 2-test-deps
  • 3-integration-suite
  • Updated Documentation

Status

WIP & Require Review!!!

@lihaoyi
Copy link
Member

lihaoyi commented Dec 23, 2024

CC @jodersky to take a look

@himanshumahajan138
Copy link
Contributor Author

{@lihaoyi & @jodersky} Sir It's Done and Ready for final Review...

There is no Requirement for deep review coz its almost same as scalalib and other testing Examples still i would say let's Review and Finalize this PR...

@himanshumahajan138
Copy link
Contributor Author

it's been 3 days since completion But no Review 🥺

@jodersky
Copy link
Member

jodersky commented Dec 27, 2024 via email

@himanshumahajan138
Copy link
Contributor Author

himanshumahajan138 commented Dec 27, 2024

@jodersky No Worries, Sir we can wait till 2025 start, after New Year we can work on this....

BTW Happy New Year ✨

Thanks for Your Response 🤞

@jodersky
Copy link
Member

jodersky commented Jan 2, 2025

Hey @himanshumahajan138 , happy new year! Just got back

@himanshumahajan138
Copy link
Contributor Author

himanshumahajan138 commented Jan 3, 2025

@jodersky Sir i dont think this failing python testcase should fail in general what u say ?

[3980] X mill.testkit.UtestExampleTestSuite.exampleTest 71829ms 
[3980]   utest.AssertionError: assert(filteredOut.linesIterator.exists(globMatches(expectedLine, _)))
[3980]   filteredOut: String = Collecting mypy==1.13.0
[3980]     Using cached mypy-1.13.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.metadata (2.1 kB)
[3980]   Collecting pex==2.24.1
[3980]     Using cached pex-2.24.1-py2.py3-none-any.whl.metadata (7.6 kB)
[3980]   Collecting typing-extensions>=4.6.0 (from mypy==1.13.0)
[3980]     Using cached typing_extensions-4.12.2-py3-none-any.whl.metadata (3.0 kB)
[3980]   Collecting mypy-extensions>=1.0.0 (from mypy==1.13.0)
[3980]     Using cached mypy_extensions-1.0.0-py3-none-any.whl.metadata (1.1 kB)
[3980]   Using cached mypy-1.13.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (12.6 MB)
[3980]   Using cached pex-2.24.1-py2.py3-none-any.whl (3.6 MB)
[3980]   Using cached mypy_extensions-1.0.0-py3-none-any.whl (4.7 kB)
[3980]   Using cached typing_extensions-4.12.2-py3-none-any.whl (37 kB)
[3980]   Installing collected packages: typing-extensions, pex, mypy-extensions, mypy
[3980]   Successfully installed mypy-1.13.0 mypy-extensions-1.0.0 pex-2.24.1 typing-extensions-4.12.2
[3980]   test_mean (test.TestScript.test_mean) ... Using BarTestUtils.bar_assert_equals
[3980]   ok
[3980]   ----------------------------------------------------------------------
[3980]   Ran 1 test in 0.000s
[3980]   OK
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]   expectedLine: String = ...test_mean (test.TestScript...)...ok...
[3980]     utest.asserts.Asserts$.assertImpl(Asserts.scala:30)
[3980]     mill.testkit.ExampleTester.$anonfun$validateEval$7(ExampleTester.scala:171)
[3980]     mill.testkit.ExampleTester.$anonfun$validateEval$7$adapted(ExampleTester.scala:170)
[3980]     scala.collection.IterableOnceOps.foreach(IterableOnce.scala:619)
[3980]     scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:617)
[3980]     scala.collection.AbstractIterator.foreach(Iterator.scala:1[303](https://github.com/com-lihaoyi/mill/actions/runs/12596075634/job/35106699515?pr=4166#step:11:304))
[3980]     mill.testkit.ExampleTester.validateEval(ExampleTester.scala:170)
[3980]     mill.testkit.ExampleTester.processCommand(ExampleTester.scala:134)
[3980]     mill.testkit.ExampleTester.processCommandBlock(ExampleTester.scala:95)
[3980]     mill.testkit.ExampleTester.$anonfun$run$2(ExampleTester.scala:194)
[3980]     mill.testkit.ExampleTester.$anonfun$run$2$adapted(ExampleTester.scala:194)
[3980]     scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[3980]     mill.testkit.ExampleTester.run(ExampleTester.scala:194)
[3980]     mill.testkit.ExampleTester$.run(ExampleTester.scala:61)
[3980]     mill.testkit.UtestExampleTestSuite$.$anonfun$tests$3(UtestExampleTestSuite.scala:19)
[3980]     scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
[3980]     mill.api.Retry.$anonfun$apply$1(Retry.scala:32)
[3980]     mill.api.Retry.$anonfun$apply$1$adapted(Retry.scala:32)
[3980]     mill.api.Retry.$anonfun$indexed$2(Retry.scala:42)
[3980]     scala.util.Try$.apply(Try.scala:217)
[3980]     mill.api.Retry.$anonfun$indexed$1(Retry.scala:42)
[3980]     java.lang.Thread.run(Thread.java:840)
[3980] Tests: 1, Passed: 0, Failed: 1
[3980] [3980] example.pythonlib.testing[2-test-deps].local.test failed

Copy link
Member

@jodersky jodersky left a comment

Choose a reason for hiding this comment

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

Thanks for your patience @himanshumahajan138 I finally got to reviewing your PR.

It think it's looking good, but there are still a few changes to be made before we can merge it

docs/modules/ROOT/pages/pythonlib/testing.adoc Outdated Show resolved Hide resolved
example/pythonlib/testing/1-test-suite/build.mill Outdated Show resolved Hide resolved
example/pythonlib/testing/1-test-suite/build.mill Outdated Show resolved Hide resolved
example/pythonlib/testing/2-test-deps/build.mill Outdated Show resolved Hide resolved
example/pythonlib/testing/2-test-deps/bar/test/src/test.py Outdated Show resolved Hide resolved

object test extends PythonTests with TestModule.Unittest {
def moduleDeps = super.moduleDeps ++ Seq(bar.test)

Copy link
Member

Choose a reason for hiding this comment

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

it would be nice to show pythonDeps used here too, since it's mentioned in the text above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup why not !

i will use the inbuilt libs which we are also using in the backend just for demo purposes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

one thing i want to mention is that if i added some library in the foo object then it will be available for test also(you know this)

so why we should add some libs demo in test ?

Altough i have added still for demo Purpose

Copy link
Member

@jodersky jodersky Jan 5, 2025

Choose a reason for hiding this comment

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

I think it would be better to add a python dependency to the test and use that.

so why we should add some libs demo in test ?

The reason is to show how a user can use a library in tests (for example a helper function), but not depend on it in the main module

Once that is done, you have green light to merge from me. However I'd like @lihaoyi to sign off first due to the failing CI test which appears to be unrelated, but I don't want to take any chances

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sir let choose one thing and add something you too want...

  1. Use some library in the test which we will use only in test object and show that example on top of this
  2. Add some test library in the test (maybe PyTest) and use that to perform test

Add your requirement in these with instruction please

Moreover, i think that this failing testcase is Flaky and will get passed on multiple runs (on its own)

example/pythonlib/testing/2-test-deps/build.mill Outdated Show resolved Hide resolved
@himanshumahajan138
Copy link
Contributor Author

@jodersky its great to see you back ✨

Thanks for Reviewing!

let me Update the Code and then Finalize this and move ahead to further support 🤞

@himanshumahajan138
Copy link
Contributor Author

@jodersky Sir All Done ✨

Let's get up in Contribution Leaderboard 🤞

Copy link
Member

@jodersky jodersky left a comment

Choose a reason for hiding this comment

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

Almost there! If you can show pythonDeps being used in tests then I think this is good to go.

Not sure what's up with the failing android test. Let's retry once more

example/pythonlib/testing/2-test-deps/build.mill Outdated Show resolved Hide resolved
@himanshumahajan138
Copy link
Contributor Author

himanshumahajan138 commented Jan 4, 2025

Not sure what's up with the failing android test. Let's retry once more

Actually Mill's CI have some type of personal issue(grudge) with me i.e why it always fails irrelevantly in my PR's 😂

@himanshumahajan138
Copy link
Contributor Author

@jodersky i have added a beautiful example for 2-test-deps for including the concept of using pythonDeps

Give a Green Pass for @lihaoyi to merge this ✨ (If Satisfied)

@himanshumahajan138
Copy link
Contributor Author

@jodersky Sir, please see if i addressed your concern...

@himanshumahajan138
Copy link
Contributor Author

@lihaoyi Updated Based on Your Reviews!

@himanshumahajan138
Copy link
Contributor Author

Are we Merging ???

@lihaoyi lihaoyi merged commit b60ad32 into com-lihaoyi:main Jan 7, 2025
25 of 26 checks passed
@himanshumahajan138
Copy link
Contributor Author

@lihaoyi & @jodersky Thanks Sir for Your Support and Guide ✨

@lefou lefou added this to the 0.12.6 milestone Jan 8, 2025
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.

4 participants