@no_asan('issues with freetype itself')
@needs_make('depends on freetype')
@is_slow_test
def test_poppler(self):

    def test():
        pdf_data = open(path_from_root('tests', 'poppler', 'paper.pdf'), 'rb').read()
        create_test_file('paper.pdf.js', str(list(bytearray(pdf_data))))
        create_test_file('pre.js', '\n      Module.preRun = function() {\n        FS.createDataFile(\'/\', \'paper.pdf\', eval(read_(\'paper.pdf.js\')), true, false, false);\n      };\n      Module.postRun = function() {\n        var FileData = MEMFS.getFileDataAsRegularArray(FS.root.contents[\'filename-1.ppm\']);\n        out("Data: " + JSON.stringify(FileData.map(function(x) { return unSign(x, 8) })));\n      };\n      ')
        self.emcc_args += ['--pre-js', 'pre.js']
        ppm_data = str(list(bytearray(open(path_from_root('tests', 'poppler', 'ref.ppm'), 'rb').read())))
        self.do_run('', ppm_data.replace(' ', ''), libraries=self.get_poppler_library(), args=['-scale-to', '512', 'paper.pdf', 'filename'])
    test()
    if self.supports_js_dfe():
        print('Testing poppler with ELIMINATE_DUPLICATE_FUNCTIONS set to 1', file=sys.stderr)
        num_original_funcs = self.count_funcs('src.cpp.o.js')
        self.set_setting('ELIMINATE_DUPLICATE_FUNCTIONS', 1)
        test()
        assert ((num_original_funcs - self.count_funcs('src.cpp.o.js')) > 200)
@no_asan('issues with freetype itself')
@needs_make('depends on freetype')
@is_slow_test
def test_poppler(self):

    def test():
        pdf_data = open(path_from_root('tests', 'poppler', 'paper.pdf'), 'rb').read()
        create_test_file('paper.pdf.js', str(list(bytearray(pdf_data))))
        create_test_file('pre.js', '\n      Module.preRun = function() {\n        FS.createDataFile(\'/\', \'paper.pdf\', eval(read_(\'paper.pdf.js\')), true, false, false);\n      };\n      Module.postRun = function() {\n        var FileData = MEMFS.getFileDataAsRegularArray(FS.root.contents[\'filename-1.ppm\']);\n        out("Data: " + JSON.stringify(FileData.map(function(x) { return unSign(x, 8) })));\n      };\n      ')
        self.emcc_args += ['--pre-js', 'pre.js']
        ppm_data = str(list(bytearray(open(path_from_root('tests', 'poppler', 'ref.ppm'), 'rb').read())))
        self.do_run(, ppm_data.replace(' ', ), libraries=self.get_poppler_library(), args=['-scale-to', '512', 'paper.pdf', 'filename'])
    test()
    if self.supports_js_dfe():
        print('Testing poppler with ELIMINATE_DUPLICATE_FUNCTIONS set to 1', file=sys.stderr)
        num_original_funcs = self.count_funcs('src.cpp.o.js')
        self.set_setting('ELIMINATE_DUPLICATE_FUNCTIONS', 1)
        test()
        assert ((num_original_funcs - self.count_funcs('src.cpp.o.js')) > 200)