MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / assertFileContents

Method assertFileContents

test/common.py:1129–1145  ·  view source on GitHub ↗
(self, filename, contents, tofile=None)

Source from the content-addressed store, hash-verified

1127 self.fail(fail_message)
1128
1129 def assertFileContents(self, filename, contents, tofile=None):
1130 if EMTEST_VERBOSE:
1131 print(f'Comparing results contents of file: {filename}')
1132
1133 contents = contents.replace('\r', '')
1134
1135 if EMTEST_REBASELINE:
1136 utils.write_file(filename, contents)
1137 return
1138
1139 if not os.path.exists(filename):
1140 self.fail('Test expectation file not found: ' + filename + '.\n' +
1141 'Run with --rebaseline to generate.')
1142 expected_content = read_file(filename)
1143 message = "Run with --rebaseline to automatically update expectations"
1144 self.assertTextDataIdentical(expected_content, contents, message,
1145 filename, tofile or (filename + '.new'))
1146
1147 def assertFilesMatch(self, expected, actual):
1148 self.assertFileContents(expected, read_file(actual), tofile=actual)

Callers 7

assertFilesMatchMethod · 0.95
run_codesize_testMethod · 0.80
test_cmakeMethod · 0.80
test_js_optimizerMethod · 0.80
test_dlfcn_selfMethod · 0.80

Calls 6

read_fileFunction · 0.90
write_fileMethod · 0.80
existsMethod · 0.80
failMethod · 0.80
printFunction · 0.50

Tested by 6

run_codesize_testMethod · 0.64
test_cmakeMethod · 0.64
test_js_optimizerMethod · 0.64
test_dlfcn_selfMethod · 0.64