Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-34022: Unbreak importlib tests when SOURCE_DATE_EPOCH is set #9484

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

Closed
wants to merge 2 commits into from

Conversation

elprans
Copy link
Contributor

@elprans elprans commented Sep 21, 2018

SOURCE_DATE_EPOCH forces py_compile to use the CHECKED_HASH .pyc
invalidation mode, and some tests fail when it is enabled.

The solution is to unset SOURCE_DATE_EPOCH for tests that expect a
different invalidation mode. This also makes all relevant tests run
with SOURCE_DATE_EPOCH set explicitly.

https://bugs.python.org/issue34022

SOURCE_DATE_EPOCH forces py_compile to use the CHECKED_HASH .pyc
invalidation mode, and some tests fail when it is enabled.

The solution is to unset SOURCE_DATE_EPOCH for tests that expect a
different invalidation mode.  This also makes all relevant tests run
with SOURCE_DATE_EPOCH set explicitly.
@mcepl
Copy link
Contributor

mcepl commented Sep 22, 2018

Wouldn't it better to go in the other direction: to make tests where it matters check for the existence of the environmental variable and modify their expectations accordingly?

@elprans
Copy link
Contributor Author

elprans commented Sep 22, 2018

No. These are tests for specific invalidation behavior. Skipping or otherwise modifying the tests would lead to gaps in coverage. And SOURCE_DATE_EPOCH itself is tested elsewhere in test_py_compile.

@thehesiod
Copy link
Contributor

with this patch I'm still getting the following errors when we build 3.7.0

======================================================================
FAIL: test_force (test.test_compileall.CommandLineTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/Python-3.7.0/Lib/test/test_compileall.py", line 365, in test_force
    self.assertEqual(mtime, mtime2)
AssertionError: 1538001451.0582225 != 1538001511.103473

======================================================================
FAIL: test_no_args_respects_force_flag (test.test_compileall.CommandLineTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/Python-3.7.0/Lib/test/test_compileall.py", line 299, in test_no_args_respects_force_flag
    self.assertEqual(mtime, mtime2)
AssertionError: 1538001451.8885925 != 1538001511.943473

======================================================================
FAIL: test_pyc_invalidation_mode (test.test_compileall.CommandLineTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/Python-3.7.0/Lib/test/test_compileall.py", line 533, in test_pyc_invalidation_mode
    self.assertEqual(int.from_bytes(data[4:8], 'little'), 0b01)
AssertionError: 3 != 1

======================================================================
FAIL: test_magic_number (test.test_compileall.CompileallTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/Python-3.7.0/Lib/test/test_compileall.py", line 78, in test_magic_number
    self.recreation_check(b'\0\0\0\0')
  File "/build/Python-3.7.0/Lib/test/test_compileall.py", line 61, in recreation_check
    self.assertEqual(*self.data())
AssertionError: b'B\r\r\n\x03\x00\x00\x00\\s\xa0J' != b'B\r\r\n\x00\x00\x00\x00i\n\xac['

======================================================================
FAIL: test_mtime (test.test_compileall.CompileallTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/Python-3.7.0/Lib/test/test_compileall.py", line 74, in test_mtime
    0, 1))
  File "/build/Python-3.7.0/Lib/test/test_compileall.py", line 61, in recreation_check
    self.assertEqual(*self.data())
AssertionError: b'B\r\r\n\x03\x00\x00\x00\\s\xa0J' != b'B\r\r\n\x00\x00\x00\x00i\n\xac['

----------------------------------------------------------------------

reverting ccbe5818af2 does fix it. In particular for me I'm compiling 3.7.0 via dpkg-buildpackage -b -nc -us -uc -rfakeroot -jauto which I'm guessing somewhere sets SOURCE_DATE_EPOCH

@elprans
Copy link
Contributor Author

elprans commented Sep 27, 2018

Yes, I think that ccbe581 is broken. I'll submit another PR with a proposed fix.

@elprans
Copy link
Contributor Author

elprans commented Sep 27, 2018

Closing in favor of #9607.

@elprans elprans closed this Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.