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

Simplify tests, shorten buildir name on windows #137

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

mattip
Copy link
Contributor

@mattip mattip commented Oct 18, 2024

Taken from #135, without the pytest-xdist module name randomization

This should be smaller and easier to review:

  • explicitly test c file is not regenerated rather than retesting, should speed up tests
  • solve windows test crashes due to too-long filenames

@mattip
Copy link
Contributor Author

mattip commented Oct 21, 2024

I am not sure why CI is failing. When I run the tests locally they pass.

@arigo
Copy link
Contributor

arigo commented Oct 21, 2024

Force the tests to re-run (unsure how), and see if they still fail? If they do, force a re-run on the base (unsure how) and see if they still pass? If all that is true, then dig deeper.

@mattip mattip closed this Oct 22, 2024
@mattip mattip reopened this Oct 22, 2024
@arigo
Copy link
Contributor

arigo commented Oct 25, 2024

The failure we get is genuine. I think you can get it too by running both test_verify.py and test_vgen.py in the same run. Then it tries to load a library made in the test_verify mode while assuming it was made in the test_vgen mode, or something.

@mattip
Copy link
Contributor Author

mattip commented Oct 25, 2024

When I run the tests locally the cffi.verifier.cleanup_tmpdir() call cleans out the old module. I am not sure why in this test only the cleanup does not work.

@arigo
Copy link
Contributor

arigo commented Oct 25, 2024

Maybe the CI runs pytest-xdist anyway? Or some other pytest version, or other plugins, etc.? Something that would make the order of execution different, e.g. test_vgen.setup_module could be called before the actual tests of test_verify run.

@mattip
Copy link
Contributor Author

mattip commented Oct 25, 2024

I am stumped. No pytest-xdist plugin is used:

platform linux -- Python 3.13.0, pytest-8.3.3, pluggy-1.5.0

and the tests are run in the correct order:

  ../../../project/cffi/testing/cffi0/test_verify.py ...................s. [ 42%]
  .....s.....s............................................................ [ 46%]
  .....................................................s...s.............s [ 50%]
  s...                                                                     [ 50%]
  ../../../project/cffi/testing/cffi0/test_version.py .....                [ 51%]
  ../../../project/cffi/testing/cffi0/test_vgen.py ...................s... [ 52%]
  ...s.....s.............................................................. [ 56%]
  ...................................................s...s.............ss. [ 60%]
  .F                                

When I can I will add debug cruft to cleanup_tempdir(), maybe somehow it is skipping the module in question.

@mattip
Copy link
Contributor Author

mattip commented Oct 29, 2024

Another strange thing I noticed in the codebase: there is both testing/cffi0/test_verify.py and testing/cffi1/test_verify1.py. These files echo each other: they have many of the same tests with slight variations. Some of these repeated tests are quite "expensive" on PyPy's nightly testing on windows. For instance:

  • test_struct_bad_sized_integer takes 101 seconds
  • test_global_const_int_size takes ~75 secs

@mattip
Copy link
Contributor Author

mattip commented Oct 29, 2024

Still stumped. I used cos to make sure the test is using a unique function call and print the remaining files in the cleanup_tmp() call at the beginning of test_vgen.py, there are no remnants that might trip up the call to verify(). It still seems like something is being cached from test_verify into test_vgen somewhere.

@mattip
Copy link
Contributor Author

mattip commented Oct 29, 2024

CI was passing so I removed the debug cruft and enabled windows tests. Let's see how long it takes. I am not sure why when using a module name I had to create a unique module name but 🤷. I guess #135 avoided this problem by making all the module names unique.

@mattip
Copy link
Contributor Author

mattip commented Oct 29, 2024

25 minutes for windows tests, I guess that is acceptable? It could be less if the repetitive tests are removed from cffi0/test_verify and cffi1/test_verify1.py

@arigo
Copy link
Contributor

arigo commented Oct 29, 2024

cffi0 checks the verify() call that was in cffi 0.x.y, while cffi1 checks the new compile() call. This is very different pieces of code, even if they both implement a large common part.

@mattip
Copy link
Contributor Author

mattip commented Oct 29, 2024

Ahh, makes sense, thanks for clarifying. CI is passing, including enabling windows tests.

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.

2 participants