Skip to content

Commit 34a692d

Browse files
committed
Fix test_precompiled_headers after recent LLVM change. NFC
This was is sensitive the precise output of `clang --print-stats`. This change makes it a little less sensitive so that it passed both before and after recent llvm changes.
1 parent d4c1c6e commit 34a692d

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

test/common.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,11 +1061,6 @@ def assertIdentical(self, values, y, msg=None,
10611061
fail_message += '\n' + msg
10621062
self.fail(fail_message)
10631063

1064-
def assertTextDataContained(self, text1, text2):
1065-
text1 = text1.replace('\r\n', '\n')
1066-
text2 = text2.replace('\r\n', '\n')
1067-
return self.assertContained(text1, text2)
1068-
10691064
def assertFileContents(self, filename, contents):
10701065
if EMTEST_VERBOSE:
10711066
print(f'Comparing results contents of file: {filename}')
@@ -1108,13 +1103,16 @@ def assertContained(self, values, string, additional_info='', regex=False):
11081103
additional_info,
11091104
))
11101105

1111-
def assertNotContained(self, value, string):
1106+
def assertNotContained(self, value, string, regex=False):
11121107
if callable(value):
11131108
value = value() # lazy loading
11141109
if callable(string):
11151110
string = string()
1116-
if value in string:
1117-
self.fail("Expected to NOT find '%s' in '%s'" % (limit_size(value), limit_size(string)))
1111+
if regex:
1112+
self.assertFalse(re.search(value, string, re.DOTALL), 'Expected regex "%s" NOT to match on:\n%s' % (value, limit_size(string)))
1113+
else:
1114+
if value in string:
1115+
self.fail("Expected to NOT find '%s' in '%s'" % (limit_size(value), limit_size(string)))
11181116

11191117
def assertContainedIf(self, value, string, condition):
11201118
if condition:

test/test_other.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4523,6 +4523,7 @@ def test_precompiled_headers_warnings(self):
45234523
'gch': ['gch'],
45244524
'pch': ['pch'],
45254525
})
4526+
@crossplatform
45264527
def test_precompiled_headers(self, suffix):
45274528
create_file('header.h', '#define X 5\n')
45284529
self.run_process([EMCC, '-xc++-header', 'header.h', '-c'])
@@ -4545,11 +4546,11 @@ def test_precompiled_headers(self, suffix):
45454546

45464547
# also verify that the gch is actually used
45474548
err = self.run_process([EMXX, 'src.cpp', '-include', 'header.h', '-Xclang', '-print-stats'], stderr=PIPE).stderr
4548-
self.assertTextDataContained('*** PCH/Modules Loaded:\nModule: header.h.pch', err)
4549+
self.assertContained(r'PCH/Modules Loaded:\nModule: .*header.h.pch', err.replace('\r\n', '\n'), regex=True)
45494550
# and sanity check it is not mentioned when not
45504551
delete_file('header.h.' + suffix)
45514552
err = self.run_process([EMXX, 'src.cpp', '-include', 'header.h', '-Xclang', '-print-stats'], stderr=PIPE).stderr
4552-
self.assertNotContained('*** PCH/Modules Loaded:\nModule: header.h.' + suffix, err.replace('\r\n', '\n'))
4553+
self.assertNotContained(r'PCH/Modules Loaded:', err, regex=True)
45534554

45544555
# with specified target via -o
45554556
delete_file('header.h.' + suffix)

0 commit comments

Comments
 (0)