Skip to content

Conversation

@elprans
Copy link
Contributor

@elpranselprans 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

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
ContributorAuthor

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
ContributorAuthor

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

@elprans
Copy link
ContributorAuthor

Closing in favor of #9607.

@elpranselprans closed this Sep 27, 2018
Sign up for freeto 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

@elprans@mcepl@thehesiod@the-knights-who-say-ni@bedevere-bot