Skip to content

Commit 2414ad8

Browse files
committed
test build version mismatch reporting
1 parent a0e522b commit 2414ad8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/test_sanity.py

+18
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ def test_llvm_fastcomp(self):
242242
output = self.check_working(EMCC, 'did not see a source tree above or next to the LLVM root directory')
243243

244244
VERSION_WARNING = 'Emscripten, llvm and clang repo versions do not match, this is dangerous'
245+
BUILD_VERSION_WARNING = 'Emscripten, llvm and clang build versions do not match, this is dangerous'
245246

246247
# add version number
247248
open(path_from_root('tests', 'fake', 'emscripten-version.txt'), 'w').write('waka')
@@ -263,6 +264,23 @@ def test_llvm_fastcomp(self):
263264
try_delete(SANITY_FILE)
264265
output = self.check_working(EMCC, VERSION_WARNING)
265266

267+
# restore clang version to ok, and fake the *build* versions
268+
open(path_from_root('tests', 'fake', 'tools', 'clang', 'emscripten-version.txt'), 'w').write(EMSCRIPTEN_VERSION)
269+
output = self.check_working(EMCC)
270+
assert VERSION_WARNING not in output
271+
fake = '#!/bin/sh\necho "clang version %s (blah blah) (emscripten waka : waka)"\necho "..."\n' % '.'.join(map(str, EXPECTED_LLVM_VERSION))
272+
open(path_from_root('tests', 'fake', 'bin', 'clang'), 'w').write(fake)
273+
open(path_from_root('tests', 'fake', 'bin', 'clang++'), 'w').write(fake)
274+
os.chmod(path_from_root('tests', 'fake', 'bin', 'clang'), stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC)
275+
os.chmod(path_from_root('tests', 'fake', 'bin', 'clang++'), stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC)
276+
try_delete(SANITY_FILE)
277+
output = self.check_working(EMCC, BUILD_VERSION_WARNING)
278+
assert VERSION_WARNING not in output
279+
# break clang repo version again, see it hides the build warning
280+
open(path_from_root('tests', 'fake', 'tools', 'clang', 'emscripten-version.txt'), 'w').write('waka')
281+
output = self.check_working(EMCC, VERSION_WARNING)
282+
assert BUILD_VERSION_WARNING not in output
283+
266284
restore()
267285

268286
self.check_working([EMCC, 'tests/hello_world.cpp', '-s', 'ASM_JS=0'], '''Compiler settings are incompatible with fastcomp. You can fall back to the older compiler core, although that is not recommended''')

0 commit comments

Comments
 (0)