def test_files(self):
    self.banned_js_engines = [SPIDERMONKEY_ENGINE]
    if self.maybe_closure():
        self.emcc_args = [x for x in self.emcc_args if (x != '-g')]
    elif (('-O3' in self.emcc_args) and (not self.is_wasm())):
        print('closure 2')
        self.emcc_args += ['--closure', '2', '-Wno-almost-asm']
        return self.skipTest('TODO: currently skipped because CI runs out of memory running Closure in this test!')
    self.emcc_args += ['-s', 'FORCE_FILESYSTEM=1', '--pre-js', 'pre.js']
    print('base', self.emcc_args)
    create_test_file('pre.js', "\n/** @suppress{checkTypes}*/\nModule = {\n  'noFSInit': true,\n  'preRun': function() {\n    FS.createLazyFile('/', 'test.file', 'test.file', true, false);\n    // Test FS_* exporting\n    Module['FS_createDataFile']('/', 'somefile.binary', [100, 200, 50, 25, 10, 77, 123], true, false, false);  // 200 becomes -56, since signed chars are used in memory\n    var test_files_input = 'hi there!';\n    var test_files_input_index = 0;\n    FS.init(function() {\n      return test_files_input.charCodeAt(test_files_input_index++) || null;\n    });\n  }\n};\n")
    create_test_file('test.file', 'some data')
    src = open(path_from_root('tests', 'files.cpp')).read()
    mem_file = 'src.cpp.o.js.mem'
    try_delete(mem_file)

    def clean(out, err):
        return '\n'.join([line for line in (out + err).split('\n') if (('binaryen' not in line) and ('wasm' not in line) and ('so not running' not in line))])
    self.do_run(src, ('size: 7\ndata: 100,-56,50,25,10,77,123\nloop: 100 -56 50 25 10 77 123 \ninput:hi there!\ntexto\n$\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.\nfscanfed: 10 - hello\n5 bytes to dev/null: 5\nok.\ntexte\n', 'size: 7\ndata: 100,-56,50,25,10,77,123\nloop: 100 -56 50 25 10 77 123 \ninput:hi there!\ntexto\ntexte\n$\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.\nfscanfed: 10 - hello\n5 bytes to dev/null: 5\nok.\n'), output_nicerizer=clean)
    if self.uses_memory_init_file():
        self.assertExists(mem_file)
def test_files(self):
    self.banned_js_engines = [SPIDERMONKEY_ENGINE]
    if self.maybe_closure():
        self.emcc_args = [x for x in self.emcc_args if (x != '-g')]
    elif (('-O3' in self.emcc_args) and (not self.is_wasm())):
        print('closure 2')
        self.emcc_args += ['--closure', '2', '-Wno-almost-asm']
        return self.skipTest('TODO: currently skipped because CI runs out of memory running Closure in this test!')
    self.emcc_args += ['-s', 'FORCE_FILESYSTEM=1', '--pre-js', 'pre.js']
    print('base', self.emcc_args)
    create_test_file('pre.js', "\n/** @suppress{checkTypes}*/\nModule = {\n  'noFSInit': true,\n  'preRun': function() {\n    FS.createLazyFile('/', 'test.file', 'test.file', true, false);\n    // Test FS_* exporting\n    Module['FS_createDataFile']('/', 'somefile.binary', [100, 200, 50, 25, 10, 77, 123], true, false, false);  // 200 becomes -56, since signed chars are used in memory\n    var test_files_input = 'hi there!';\n    var test_files_input_index = 0;\n    FS.init(function() {\n      return test_files_input.charCodeAt(test_files_input_index++) || null;\n    });\n  }\n};\n")
    create_test_file('test.file', 'some data')
    src = open(path_from_root('tests', 'files.cpp')).read()
    mem_file = 'src.cpp.o.js.mem'
    try_delete(mem_file)

    def clean(out, err):
        return '\n'.join([line for line in (out + err).split('\n') if (('binaryen' not in line) and ('wasm' not in line) and ('so not running' not in line))])
    self.do_run(src, ('size: 7\ndata: 100,-56,50,25,10,77,123\nloop: 100 -56 50 25 10 77 123 \ninput:hi there!\ntexto\n$\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.\nfscanfed: 10 - hello\n5 bytes to dev/null: 5\nok.\ntexte\n', 'size: 7\ndata: 100,-56,50,25,10,77,123\nloop: 100 -56 50 25 10 77 123 \ninput:hi there!\ntexto\ntexte\n$\n5 : 10,30,20,11,88\nother=some data.\nseeked=me da.\nseeked=ata.\nseeked=ta.\nfscanfed: 10 - hello\n5 bytes to dev/null: 5\nok.\n'), output_nicerizer=clean)
    if self.uses_memory_init_file():
        self.assertExists(mem_file)