diff --git a/test/common.py b/test/common.py index 65fa4c33bd3d..3f366c2d5e53 100644 --- a/test/common.py +++ b/test/common.py @@ -2192,7 +2192,7 @@ def make_reftest(self, expected, manually_trigger=False): # make sure the pngs used here have no color correction, using e.g. # pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB infile outfile reporting = read_file(test_file('browser_reporting.js')) - shutil.copyfile(expected, 'expected.png') + shutil.copy(expected, 'expected.png') create_file('reftest.js', ''' function doReftest() { if (doReftest.done) return; diff --git a/test/test_browser.py b/test/test_browser.py index 5a3c4919eb54..e4b32d40b671 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -442,7 +442,7 @@ def test_preload_file_with_manual_data_download(self, args): create_file('file.txt', 'Hello!') self.compile_btest('browser/test_manual_download_data.c', ['-sEXIT_RUNTIME', '-o', 'out.js', '--preload-file', 'file.txt@/file.txt'] + args) - shutil.copyfile(test_file('browser/test_manual_download_data.html'), 'test_manual_download_data.html') + shutil.copy(test_file('browser/test_manual_download_data.html'), '.') # Move .data file out of server root to ensure that getPreloadedPackage is actually used os.mkdir('test') @@ -758,7 +758,7 @@ def test_sdl_surface_lock_opts(self): @also_with_wasmfs def test_sdl_image(self): # load an image file, get pixel data. Also O2 coverage for --preload-file - shutil.copyfile(test_file('screenshot.jpg'), 'screenshot.jpg') + shutil.copy(test_file('screenshot.jpg'), '.') src = test_file('browser/test_sdl_image.c') for dest, dirname, basename in [('screenshot.jpg', '/', 'screenshot.jpg'), ('screenshot.jpg@/assets/screenshot.jpg', '/assets', 'screenshot.jpg')]: @@ -769,7 +769,7 @@ def test_sdl_image(self): @also_with_wasmfs def test_sdl_image_jpeg(self): - shutil.copyfile(test_file('screenshot.jpg'), 'screenshot.jpeg') + shutil.copy(test_file('screenshot.jpg'), 'screenshot.jpeg') self.btest_exit('test_sdl_image.c', args=[ '--preload-file', 'screenshot.jpeg', '-DSCREENSHOT_DIRNAME="/"', '-DSCREENSHOT_BASENAME="screenshot.jpeg"', '--use-preload-plugins', @@ -777,7 +777,7 @@ def test_sdl_image_jpeg(self): ]) def test_sdl_image_webp(self): - shutil.copyfile(test_file('screenshot.webp'), 'screenshot.webp') + shutil.copy(test_file('screenshot.webp'), '.') self.btest_exit('test_sdl_image.c', args=[ '--preload-file', 'screenshot.webp', '-DSCREENSHOT_DIRNAME="/"', '-DSCREENSHOT_BASENAME="screenshot.webp"', '--use-preload-plugins', @@ -788,7 +788,7 @@ def test_sdl_image_webp(self): @also_with_proxying def test_sdl_image_prepare(self): # load an image file, get pixel data. - shutil.copyfile(test_file('screenshot.jpg'), 'screenshot.not') + shutil.copy(test_file('screenshot.jpg'), 'screenshot.not') self.reftest('test_sdl_image_prepare.c', 'screenshot.jpg', args=['--preload-file', 'screenshot.not', '-lSDL', '-lGL'], manually_trigger_reftest=True) @parameterized({ @@ -800,46 +800,46 @@ def test_sdl_image_prepare(self): }) def test_sdl_image_prepare_data(self, args): # load an image file, get pixel data. - shutil.copyfile(test_file('screenshot.jpg'), 'screenshot.not') + shutil.copy(test_file('screenshot.jpg'), 'screenshot.not') self.reftest('test_sdl_image_prepare_data.c', 'screenshot.jpg', args=['--preload-file', 'screenshot.not', '-lSDL', '-lGL'] + args, manually_trigger_reftest=True) def test_sdl_image_must_prepare(self): # load an image file, get pixel data. - shutil.copyfile(test_file('screenshot.jpg'), 'screenshot.jpg') + shutil.copy(test_file('screenshot.jpg'), 'screenshot.jpg') self.reftest('test_sdl_image_must_prepare.c', 'screenshot.jpg', args=['--preload-file', 'screenshot.jpg', '-lSDL', '-lGL'], manually_trigger_reftest=True) def test_sdl_stb_image(self): # load an image file, get pixel data. - shutil.copyfile(test_file('screenshot.jpg'), 'screenshot.not') + shutil.copy(test_file('screenshot.jpg'), 'screenshot.not') self.reftest('test_sdl_stb_image.c', 'screenshot.jpg', args=['-sSTB_IMAGE', '--preload-file', 'screenshot.not', '-lSDL', '-lGL']) def test_sdl_stb_image_bpp(self): # load grayscale image without alpha - shutil.copyfile(test_file('browser/test_sdl-stb-bpp1.png'), 'screenshot.not') + shutil.copy(test_file('browser/test_sdl-stb-bpp1.png'), 'screenshot.not') self.reftest('test_sdl_stb_image.c', 'test_sdl-stb-bpp1.png', args=['-sSTB_IMAGE', '--preload-file', 'screenshot.not', '-lSDL', '-lGL']) # load grayscale image with alpha self.clear() - shutil.copyfile(test_file('browser/test_sdl-stb-bpp2.png'), 'screenshot.not') + shutil.copy(test_file('browser/test_sdl-stb-bpp2.png'), 'screenshot.not') self.reftest('test_sdl_stb_image.c', 'test_sdl-stb-bpp2.png', args=['-sSTB_IMAGE', '--preload-file', 'screenshot.not', '-lSDL', '-lGL']) # load RGB image self.clear() - shutil.copyfile(test_file('browser/test_sdl-stb-bpp3.png'), 'screenshot.not') + shutil.copy(test_file('browser/test_sdl-stb-bpp3.png'), 'screenshot.not') self.reftest('test_sdl_stb_image.c', 'test_sdl-stb-bpp3.png', args=['-sSTB_IMAGE', '--preload-file', 'screenshot.not', '-lSDL', '-lGL']) # load RGBA image self.clear() - shutil.copyfile(test_file('browser/test_sdl-stb-bpp4.png'), 'screenshot.not') + shutil.copy(test_file('browser/test_sdl-stb-bpp4.png'), 'screenshot.not') self.reftest('test_sdl_stb_image.c', 'test_sdl-stb-bpp4.png', args=['-sSTB_IMAGE', '--preload-file', 'screenshot.not', '-lSDL', '-lGL']) def test_sdl_stb_image_data(self): # load an image file, get pixel data. - shutil.copyfile(test_file('screenshot.jpg'), 'screenshot.not') + shutil.copy(test_file('screenshot.jpg'), 'screenshot.not') self.reftest('test_sdl_stb_image_data.c', 'screenshot.jpg', args=['-sSTB_IMAGE', '--preload-file', 'screenshot.not', '-lSDL', '-lGL']) def test_sdl_stb_image_cleanup(self): - shutil.copyfile(test_file('screenshot.jpg'), 'screenshot.not') + shutil.copy(test_file('screenshot.jpg'), 'screenshot.not') self.btest_exit('test_sdl_stb_image_cleanup.c', args=['-sSTB_IMAGE', '--preload-file', 'screenshot.not', '-lSDL', '-lGL', '--memoryprofiler']) @parameterized({ @@ -924,7 +924,7 @@ def test_sdl_key(self, delay, async_, defines): self.btest_exit('test_sdl_key.c', 223092870, args=defines + async_ + ['--pre-js', test_file('browser/fake_events.js'), '--pre-js=pre.js', '-lSDL', '-lGL']) def test_sdl_key_proxy(self): - shutil.copyfile(test_file('browser/fake_events.js'), 'fake_events.js') + shutil.copy(test_file('browser/fake_events.js'), '.') create_file('pre.js', ''' Module.postRun = () => { function doOne() { @@ -977,7 +977,7 @@ def post(): create_file('test.html', html) - shutil.copyfile(test_file('browser/fake_events.js'), 'fake_events.js') + shutil.copy(test_file('browser/fake_events.js'), '.') self.btest_exit('browser/test_keydown_preventdefault_proxy.c', 300, args=['--proxy-to-worker'], post_build=post) def test_sdl_text(self): @@ -1211,7 +1211,7 @@ def test_webgl_context_attributes(self): # Copy common code file to temporary directory filepath = test_file('browser/test_webgl_context_attributes_common.c') temp_filepath = os.path.basename(filepath) - shutil.copyfile(filepath, temp_filepath) + shutil.copy(filepath, temp_filepath) # testAntiAliasing uses a window-sized buffer on the stack self.set_setting('STACK_SIZE', '1MB') @@ -1380,9 +1380,9 @@ def test_fs_lz4fs_package(self): os.mkdir('files') except OSError: pass - shutil.copyfile('file1.txt', Path('files/file1.txt')) - shutil.copyfile('file2.txt', Path('files/file2.txt')) - shutil.copyfile('file3.txt', Path('files/file3.txt')) + shutil.copy('file1.txt', 'files/')) + shutil.copy('file2.txt', 'files/')) + shutil.copy('file3.txt', 'files/')) out = subprocess.check_output([FILE_PACKAGER, 'files.data', '--preload', 'files/file1.txt', 'files/file2.txt', 'files/file3.txt']) create_file('files.js', out, binary=True) self.btest_exit('fs/test_lz4fs.cpp', 2, args=['--pre-js', 'files.js'])''' @@ -1440,62 +1440,62 @@ def test_sdl_gl_mapbuffers(self): @requires_graphics_hardware def test_sdl_ogl(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl_ogl.c', 'screenshot-gray-purple.png', reference_slack=1, args=['-O2', '--minify=0', '--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '--use-preload-plugins', '-lSDL', '-lGL']) @requires_graphics_hardware def test_sdl_ogl_regal(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl_ogl.c', 'screenshot-gray-purple.png', reference_slack=1, args=['-O2', '--minify=0', '--preload-file', 'screenshot.png', '-sUSE_REGAL', '-DUSE_REGAL', '--use-preload-plugins', '-lSDL', '-lGL', '-lc++', '-lc++abi']) @requires_graphics_hardware def test_sdl_ogl_defaultmatrixmode(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl_ogl_defaultMatrixMode.c', 'screenshot-gray-purple.png', reference_slack=1, args=['--minify=0', '--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '--use-preload-plugins', '-lSDL', '-lGL']) @requires_graphics_hardware def test_sdl_ogl_p(self): # Immediate mode with pointers - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl_ogl_p.c', 'screenshot-gray.png', reference_slack=1, args=['--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '--use-preload-plugins', '-lSDL', '-lGL']) @requires_graphics_hardware def test_sdl_ogl_proc_alias(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl_ogl_proc_alias.c', 'screenshot-gray-purple.png', reference_slack=1, args=['-O2', '-g2', '-sINLINING_LIMIT', '--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '-sGL_ENABLE_GET_PROC_ADDRESS', '--use-preload-plugins', '-lSDL', '-lGL']) @requires_graphics_hardware def test_sdl_fog_simple(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl_fog_simple.c', 'screenshot-fog-simple.png', args=['-O2', '--minify=0', '--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '--use-preload-plugins', '-lSDL', '-lGL']) @requires_graphics_hardware def test_sdl_fog_negative(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl_fog_negative.c', 'screenshot-fog-negative.png', args=['--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '--use-preload-plugins', '-lSDL', '-lGL']) @requires_graphics_hardware def test_sdl_fog_density(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl_fog_density.c', 'screenshot-fog-density.png', args=['--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '--use-preload-plugins', '-lSDL', '-lGL']) @requires_graphics_hardware def test_sdl_fog_exp2(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl_fog_exp2.c', 'screenshot-fog-exp2.png', args=['--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '--use-preload-plugins', '-lSDL', '-lGL']) @requires_graphics_hardware def test_sdl_fog_linear(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl_fog_linear.c', 'screenshot-fog-linear.png', reference_slack=1, args=['--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '--use-preload-plugins', '-lSDL', '-lGL']) @@ -1682,7 +1682,7 @@ def test_glgears_long(self, args): 'full_944': ('hello_world_gles_full_944.c',), }) def test_glgears_animation(self, filename): - shutil.copyfile(test_file('browser/fake_events.js'), 'fake_events.js') + shutil.copy(test_file('browser/fake_events.js'), '.') args = ['-o', 'something.html', '-DHAVE_BUILTIN_SINCOS', '-sGL_TESTING', '-lGL', '-lglut', '--shell-file', test_file('hello_world_gles_shell.html')] @@ -1723,11 +1723,11 @@ def book_path(path): basename = os.path.basename(program) args = ['-lGL', '-lEGL', '-lX11'] if basename == 'CH10_MultiTexture.o': - shutil.copyfile(book_path('Chapter_10/MultiTexture/basemap.tga'), 'basemap.tga') - shutil.copyfile(book_path('Chapter_10/MultiTexture/lightmap.tga'), 'lightmap.tga') + shutil.copy(book_path('Chapter_10/MultiTexture/basemap.tga'), '.') + shutil.copy(book_path('Chapter_10/MultiTexture/lightmap.tga'), '.') args += ['--preload-file', 'basemap.tga', '--preload-file', 'lightmap.tga'] elif basename == 'CH13_ParticleSystem.o': - shutil.copyfile(book_path('Chapter_13/ParticleSystem/smoke.tga'), 'smoke.tga') + shutil.copy(book_path('Chapter_13/ParticleSystem/smoke.tga'), '.') args += ['--preload-file', 'smoke.tga', '-O2'] # test optimizations and closure here as well for more coverage self.reftest(program, book_path(basename.replace('.o', '.png')), args=args) @@ -1739,9 +1739,9 @@ def book_path(path): 'full_es3': (['-sFULL_ES3'],) }) def test_gles2_emulation(self, args): - shutil.copyfile(test_file('third_party/glbook/Chapter_10/MultiTexture/basemap.tga'), 'basemap.tga') - shutil.copyfile(test_file('third_party/glbook/Chapter_10/MultiTexture/lightmap.tga'), 'lightmap.tga') - shutil.copyfile(test_file('third_party/glbook/Chapter_13/ParticleSystem/smoke.tga'), 'smoke.tga') + shutil.copy(test_file('third_party/glbook/Chapter_10/MultiTexture/basemap.tga'), '.') + shutil.copy(test_file('third_party/glbook/Chapter_10/MultiTexture/lightmap.tga'), '.') + shutil.copy(test_file('third_party/glbook/Chapter_13/ParticleSystem/smoke.tga'), '.') for source, reference in [ ('third_party/glbook/Chapter_2/Hello_Triangle/Hello_Triangle_orig.c', 'third_party/glbook/CH02_HelloTriangle.png'), @@ -1787,7 +1787,7 @@ def setup(): setup() ensure_dir('sub') self.run_process([FILE_PACKAGER, 'sub/test.data', '--preload', 'file1.txt', 'file2.txt'], stdout=open('script2.js', 'w')) - shutil.copyfile(Path('sub/test.data'), 'test.data') + shutil.copy(Path('sub/test.data'), '.') self.btest_exit('test_emscripten_async_load_script.c', args=['-sFORCE_FILESYSTEM']) def test_emscripten_api_infloop(self): @@ -1795,7 +1795,7 @@ def test_emscripten_api_infloop(self): @also_with_wasmfs def test_emscripten_fs_api(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') # preloaded *after* run + shutil.copy(test_file('screenshot.png'), '.') # preloaded *after* run self.btest_exit('emscripten_fs_api_browser.c', assert_returncode=1, args=['-lSDL']) def test_emscripten_fs_api2(self): @@ -1891,24 +1891,24 @@ def test_gl_textures(self, args): @requires_graphics_hardware def test_gl_ps(self): # pointers and a shader - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('gl_ps.c', 'gl_ps.png', args=['--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL', '--use-preload-plugins'], reference_slack=1) @requires_graphics_hardware def test_gl_ps_packed(self): # packed data that needs to be strided - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('gl_ps_packed.c', 'gl_ps.png', args=['--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL', '--use-preload-plugins'], reference_slack=1) @requires_graphics_hardware def test_gl_ps_strides(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('gl_ps_strides.c', 'gl_ps_strides.png', args=['--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL', '--use-preload-plugins']) @requires_graphics_hardware @also_with_proxying def test_gl_ps_worker(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('gl_ps_worker.c', 'gl_ps.png', args=['--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL', '--use-preload-plugins'], reference_slack=1) @requires_graphics_hardware @@ -2128,7 +2128,7 @@ def test_sdl_create_rgb_surface_from(self): self.reftest('test_sdl_create_rgb_surface_from.c', 'test_sdl_create_rgb_surface_from.png', args=['-lSDL', '-lGL']) def test_sdl_rotozoom(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl_rotozoom.c', 'test_sdl_rotozoom.png', args=['--preload-file', 'screenshot.png', '--use-preload-plugins', '-lSDL', '-lGL'], reference_slack=3) def test_sdl_gfx_primitives(self): @@ -2171,17 +2171,17 @@ def test_sdl_free_screen(self): @requires_graphics_hardware def test_glbegin_points(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('glbegin_points.c', 'glbegin_points.png', args=['--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL', '--use-preload-plugins']) @requires_graphics_hardware def test_s3tc(self): - shutil.copyfile(test_file('screenshot.dds'), 'screenshot.dds') + shutil.copy(test_file('screenshot.dds'), '.') self.reftest('s3tc.c', 's3tc.png', args=['--preload-file', 'screenshot.dds', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL']) @requires_graphics_hardware def test_s3tc_ffp_only(self): - shutil.copyfile(test_file('screenshot.dds'), 'screenshot.dds') + shutil.copy(test_file('screenshot.dds'), '.') self.reftest('s3tc.c', 's3tc.png', args=['--preload-file', 'screenshot.dds', '-sLEGACY_GL_EMULATION', '-sGL_FFP_ONLY', '-lGL', '-lSDL']) @requires_graphics_hardware @@ -2190,7 +2190,7 @@ def test_s3tc_ffp_only(self): 'subimage': (['-DTEST_TEXSUBIMAGE'],), }) def test_anisotropic(self, args): - shutil.copyfile(test_file('browser/water.dds'), 'water.dds') + shutil.copy(test_file('browser/water.dds'), '.') self.reftest('test_anisotropic.c', 'test_anisotropic.png', reference_slack=2, args=['--preload-file', 'water.dds', '-sLEGACY_GL_EMULATION', '-lGL', '-lSDL', '-Wno-incompatible-pointer-types'] + args) @requires_graphics_hardware @@ -2813,7 +2813,7 @@ def test_glfw3_hi_dpi_aware(self): @also_with_wasm2js def test_sdl2_image(self): # load an image file, get pixel data. Also O2 coverage for --preload-file - shutil.copyfile(test_file('screenshot.jpg'), 'screenshot.jpg') + shutil.copy(test_file('screenshot.jpg'), '.') for dest, dirname, basename in [('screenshot.jpg', '/', 'screenshot.jpg'), ('screenshot.jpg@/assets/screenshot.jpg', '/assets', 'screenshot.jpg')]: @@ -2827,7 +2827,7 @@ def test_sdl2_image(self): @requires_graphics_hardware def test_sdl2_image_jpeg(self): - shutil.copyfile(test_file('screenshot.jpg'), 'screenshot.jpeg') + shutil.copy(test_file('screenshot.jpg'), 'screenshot.jpeg') self.btest_exit('test_sdl2_image.c', 600, args=[ '--preload-file', 'screenshot.jpeg', '-DSCREENSHOT_DIRNAME="/"', '-DSCREENSHOT_BASENAME="screenshot.jpeg"', @@ -2837,8 +2837,8 @@ def test_sdl2_image_jpeg(self): @also_with_wasmfs @requires_graphics_hardware def test_sdl2_image_formats(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') - shutil.copyfile(test_file('screenshot.jpg'), 'screenshot.jpg') + shutil.copy(test_file('screenshot.png'), '.') + shutil.copy(test_file('screenshot.jpg'), '.') self.btest_exit('test_sdl2_image.c', 512, args=[ '--preload-file', 'screenshot.png', '-DSCREENSHOT_DIRNAME="/"', '-DSCREENSHOT_BASENAME="screenshot.png"', '-DNO_PRELOADED', @@ -2972,13 +2972,13 @@ def test_sdl2_swsurface(self): @requires_graphics_hardware def test_sdl2_image_prepare(self): # load an image file, get pixel data. - shutil.copyfile(test_file('screenshot.jpg'), 'screenshot.not') + shutil.copy(test_file('screenshot.jpg'), 'screenshot.not') self.reftest('test_sdl2_image_prepare.c', 'screenshot.jpg', args=['--preload-file', 'screenshot.not', '-sUSE_SDL=2', '-sUSE_SDL_IMAGE=2'], manually_trigger_reftest=True) @requires_graphics_hardware def test_sdl2_image_prepare_data(self): # load an image file, get pixel data. - shutil.copyfile(test_file('screenshot.jpg'), 'screenshot.not') + shutil.copy(test_file('screenshot.jpg'), 'screenshot.not') self.reftest('test_sdl2_image_prepare_data.c', 'screenshot.jpg', args=['--preload-file', 'screenshot.not', '-sUSE_SDL=2', '-sUSE_SDL_IMAGE=2'], manually_trigger_reftest=True) @requires_graphics_hardware @@ -3025,31 +3025,31 @@ def test_sdl2_glalphatest(self): @requires_graphics_hardware def test_sdl2_fog_simple(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl2_fog_simple.c', 'screenshot-fog-simple.png', args=['-sUSE_SDL=2', '-sUSE_SDL_IMAGE=2', '-O2', '--minify=0', '--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '--use-preload-plugins']) @requires_graphics_hardware def test_sdl2_fog_negative(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl2_fog_negative.c', 'screenshot-fog-negative.png', args=['-sUSE_SDL=2', '-sUSE_SDL_IMAGE=2', '--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '--use-preload-plugins']) @requires_graphics_hardware def test_sdl2_fog_density(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl2_fog_density.c', 'screenshot-fog-density.png', args=['-sUSE_SDL=2', '-sUSE_SDL_IMAGE=2', '--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '--use-preload-plugins']) @requires_graphics_hardware def test_sdl2_fog_exp2(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl2_fog_exp2.c', 'screenshot-fog-exp2.png', args=['-sUSE_SDL=2', '-sUSE_SDL_IMAGE=2', '--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '--use-preload-plugins']) @requires_graphics_hardware def test_sdl2_fog_linear(self): - shutil.copyfile(test_file('screenshot.png'), 'screenshot.png') + shutil.copy(test_file('screenshot.png'), '.') self.reftest('test_sdl2_fog_linear.c', 'screenshot-fog-linear.png', reference_slack=1, args=['-sUSE_SDL=2', '-sUSE_SDL_IMAGE=2', '--preload-file', 'screenshot.png', '-sLEGACY_GL_EMULATION', '--use-preload-plugins']) @@ -3078,7 +3078,7 @@ def test_sdl2_ttf_rtl(self): args=['-O2', '-sUSE_SDL=2', '-sUSE_SDL_TTF=2', '--embed-file', 'NotoNaskhArabic-Regular.ttf']) def test_sdl2_custom_cursor(self): - shutil.copyfile(test_file('cursor.bmp'), 'cursor.bmp') + shutil.copy(test_file('cursor.bmp'), '.') self.btest_exit('test_sdl2_custom_cursor.c', args=['--preload-file', 'cursor.bmp', '-sUSE_SDL=2']) def test_sdl2_misc(self): @@ -3098,7 +3098,7 @@ def test_sdl2_misc_via_object(self): }) @requires_sound_hardware def test_sdl2_mixer_wav(self, flags): - shutil.copyfile(test_file('sounds/the_entertainer.wav'), 'sound.wav') + shutil.copy(test_file('sounds/the_entertainer.wav'), 'sound.wav') self.btest_exit('test_sdl2_mixer_wav.c', args=['--preload-file', 'sound.wav'] + flags) @parameterized({ @@ -3111,7 +3111,7 @@ def test_sdl2_mixer_wav(self, flags): }) @requires_sound_hardware def test_sdl2_mixer_music(self, formats, flags, music_name): - shutil.copyfile(test_file('sounds', music_name), music_name) + shutil.copy(test_file('sounds', music_name), '.') args = [ '--preload-file', music_name, '-DSOUND_PATH="%s"' % music_name, @@ -3392,7 +3392,7 @@ def test_dylink(self, args): } ''') self.emcc('side.c', ['-sSIDE_MODULE', '-O2', '-o', 'side.wasm']) - self.btest_exit(self.in_dir('main.c'), args=['-sMAIN_MODULE=2', '-O2', 'side.wasm'] + args) + self.btest_exit('main.c', args=['-sMAIN_MODULE=2', '-O2', 'side.wasm'] + args) def test_dlopen_async(self): create_file('side.c', 'int foo = 42;\n') @@ -3447,7 +3447,7 @@ def do_run(src, expected_output, emcc_args): # --proxy-to-worker only on main if inworker: emcc_args += ['--proxy-to-worker'] - self.btest_exit(self.in_dir('test_dylink_dso_needed.c'), args=['--post-js', 'post.js'] + emcc_args) + self.btest_exit('test_dylink_dso_needed.c', args=['--post-js', 'post.js'] + emcc_args) self._test_dylink_dso_needed(do_run) @@ -3477,7 +3477,7 @@ def test_dylink_glemu(self): ''') self.emcc('side.c', ['-sSIDE_MODULE', '-O2', '-o', 'side.wasm', '-lSDL']) - self.btest_exit(self.in_dir('main.c'), args=['-sMAIN_MODULE=2', '-O2', '-sLEGACY_GL_EMULATION', '-lSDL', '-lGL', 'side.wasm']) + self.btest_exit('main.c', args=['-sMAIN_MODULE=2', '-O2', '-sLEGACY_GL_EMULATION', '-lSDL', '-lGL', 'side.wasm']) def test_dylink_many(self): # test asynchronously loading two side modules during startup @@ -3499,7 +3499,7 @@ def test_dylink_many(self): ''') self.emcc('side1.c', ['-sSIDE_MODULE', '-o', 'side1.wasm']) self.emcc('side2.c', ['-sSIDE_MODULE', '-o', 'side2.wasm']) - self.btest_exit(self.in_dir('main.c'), args=['-sMAIN_MODULE=2', 'side1.wasm', 'side2.wasm']) + self.btest_exit('main.c', args=['-sMAIN_MODULE=2', 'side1.wasm', 'side2.wasm']) def test_dylink_pthread_many(self): # Test asynchronously loading two side modules during startup @@ -4005,7 +4005,7 @@ def test_main_thread_async_em_asm(self): self.btest_exit('core/test_main_thread_async_em_asm.cpp', args=['-O3', '-pthread', '-sPROXY_TO_PTHREAD', '-sASSERTIONS']) def test_main_thread_em_asm_blocking(self): - shutil.copyfile(test_file('browser/test_em_asm_blocking.html'), 'page.html') + shutil.copy(test_file('browser/test_em_asm_blocking.html'), 'page.html') self.compile_btest('browser/test_em_asm_blocking.cpp', ['-O2', '-o', 'wasm.js', '-pthread', '-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME']) self.run_browser('page.html', '/report_result?exit:8') @@ -4087,7 +4087,7 @@ def test_manual_wasm_instantiate(self, args): if self.is_2gb() or self.is_4gb(): self.skipTest('asan doesnt support GLOBAL_BASE') self.compile_btest('manual_wasm_instantiate.cpp', ['-o', 'manual_wasm_instantiate.js'] + args) - shutil.copyfile(test_file('manual_wasm_instantiate.html'), 'manual_wasm_instantiate.html') + shutil.copy(test_file('manual_wasm_instantiate.html'), '.') self.run_browser('manual_wasm_instantiate.html', '/report_result?1') def test_wasm_locate_file(self): @@ -4388,7 +4388,7 @@ def test_fetch_to_memory(self): args=['-sFETCH_DEBUG', '-sFETCH', '-DFILE_DOES_NOT_EXIST']) # Test the positive case when the file URL exists. (http 200) - shutil.copyfile(test_file('gears.png'), 'gears.png') + shutil.copy(test_file('gears.png'), '.') for arg in ([], ['-sFETCH_SUPPORT_INDEXEDDB=0']): self.btest_exit('fetch/test_fetch_to_memory.cpp', args=['-sFETCH_DEBUG', '-sFETCH'] + arg) @@ -4400,26 +4400,26 @@ def test_fetch_to_memory(self): @no_firefox('https://github.com/emscripten-core/emscripten/issues/16868') @also_with_wasm2js def test_fetch_from_thread(self, args): - shutil.copyfile(test_file('gears.png'), 'gears.png') + shutil.copy(test_file('gears.png'), '.') self.btest_exit('fetch/test_fetch_from_thread.cpp', args=args + ['-pthread', '-sPROXY_TO_PTHREAD', '-sFETCH_DEBUG', '-sFETCH', '-DFILE_DOES_NOT_EXIST']) @also_with_wasm2js def test_fetch_to_indexdb(self): - shutil.copyfile(test_file('gears.png'), 'gears.png') + shutil.copy(test_file('gears.png'), '.') self.btest_exit('fetch/test_fetch_to_indexeddb.cpp', args=['-sFETCH_DEBUG', '-sFETCH']) # Tests emscripten_fetch() usage to persist an XHR into IndexedDB and subsequently load up from there. @also_with_wasm2js def test_fetch_cached_xhr(self): - shutil.copyfile(test_file('gears.png'), 'gears.png') + shutil.copy(test_file('gears.png'), '.') self.btest_exit('fetch/test_fetch_cached_xhr.cpp', args=['-sFETCH_DEBUG', '-sFETCH']) # Tests that response headers get set on emscripten_fetch_t values. @no_firefox('https://github.com/emscripten-core/emscripten/issues/16868') @also_with_wasm2js def test_fetch_response_headers(self): - shutil.copyfile(test_file('gears.png'), 'gears.png') + shutil.copy(test_file('gears.png'), '.') self.btest_exit('fetch/test_fetch_response_headers.cpp', args=['-sFETCH_DEBUG', '-sFETCH', '-pthread', '-sPROXY_TO_PTHREAD']) # Test emscripten_fetch() usage to stream a XHR in to memory without storing the full file in memory @@ -4441,7 +4441,7 @@ def test_fetch_headers_received(self): self.btest_exit('fetch/test_fetch_headers_received.c', args=['-sFETCH_DEBUG', '-sFETCH']) def test_fetch_xhr_abort(self): - shutil.copyfile(test_file('gears.png'), 'gears.png') + shutil.copy(test_file('gears.png'), '.') self.btest_exit('fetch/test_fetch_xhr_abort.cpp', args=['-sFETCH_DEBUG', '-sFETCH']) # Tests emscripten_fetch() usage in synchronous mode when used from the main @@ -4449,20 +4449,20 @@ def test_fetch_xhr_abort(self): @no_firefox('https://github.com/emscripten-core/emscripten/issues/16868') @also_with_wasm2js def test_fetch_sync_xhr(self): - shutil.copyfile(test_file('gears.png'), 'gears.png') + shutil.copy(test_file('gears.png'), '.') self.btest_exit('fetch/test_fetch_sync_xhr.cpp', args=['-sFETCH_DEBUG', '-sFETCH', '-pthread', '-sPROXY_TO_PTHREAD']) # Tests synchronous emscripten_fetch() usage from pthread @no_firefox('https://github.com/emscripten-core/emscripten/issues/16868') def test_fetch_sync(self): - shutil.copyfile(test_file('gears.png'), 'gears.png') + shutil.copy(test_file('gears.png'), '.') self.btest_exit('fetch/test_fetch_sync.c', args=['-sFETCH', '-pthread', '-sPROXY_TO_PTHREAD']) # Tests that the Fetch API works for synchronous XHRs when used with --proxy-to-worker. @no_firefox('https://github.com/emscripten-core/emscripten/issues/16868') @also_with_wasm2js def test_fetch_sync_xhr_in_proxy_to_worker(self): - shutil.copyfile(test_file('gears.png'), 'gears.png') + shutil.copy(test_file('gears.png'), '.') self.btest_exit('fetch/test_fetch_sync_xhr.cpp', args=['-sFETCH_DEBUG', '-sFETCH', '--proxy-to-worker']) @@ -4472,7 +4472,7 @@ def test_fetch_idb_store(self): @disabled('https://github.com/emscripten-core/emscripten/issues/16746') def test_fetch_idb_delete(self): - shutil.copyfile(test_file('gears.png'), 'gears.png') + shutil.copy(test_file('gears.png'), '.') self.btest_exit('fetch/test_fetch_idb_delete.cpp', args=['-pthread', '-sFETCH_DEBUG', '-sFETCH', '-sWASM=0', '-sPROXY_TO_PTHREAD']) def test_fetch_post(self): @@ -4528,7 +4528,7 @@ def test_emscripten_get_device_pixel_ratio(self, args): 'mt': (['-pthread', '-sPROXY_TO_PTHREAD'],), }) def test_pthread_run_script(self, args): - shutil.copyfile(test_file('pthread/foo.js'), 'foo.js') + shutil.copy(test_file('pthread/foo.js'), '.') self.btest_exit('pthread/test_pthread_run_script.c', args=['-O3'] + args) # Tests emscripten_set_canvas_element_size() and OffscreenCanvas functionality in different build configurations. @@ -4615,7 +4615,7 @@ def test_load_js_from_blob_with_pthreads(self): # Now run the test with the JS file renamed and with its content # stored in Module['mainScriptUrlOrBlob']. shutil.move('out.js', 'hello_thread_with_blob_url.js') - shutil.copyfile(test_file('pthread/main_js_as_blob_loader.html'), 'hello_thread_with_blob_url.html') + shutil.copy(test_file('pthread/main_js_as_blob_loader.html'), 'hello_thread_with_blob_url.html') self.run_browser('hello_thread_with_blob_url.html', '/report_result?exit:0') # Tests that SINGLE_FILE works as intended in generated HTML (with and without Worker) @@ -4925,7 +4925,7 @@ def test_wasm2js_fallback_on_wasm_compilation_failure(self, args): # Restore the .wasm.js file, then corrupt the .wasm file, that should trigger the Wasm2js fallback to run os.rename('test.wasm.js.unused', 'test.wasm.js') - shutil.copyfile('test.js', 'test.wasm') + shutil.copy('test.js', 'test.wasm') self.run_browser('test.html', '/report_result?exit:0') def test_system(self): @@ -5373,7 +5373,7 @@ def test_webpack(self, es6): with utils.chdir('webpack'): self.compile_btest('hello_world.c', ['-sEXIT_RUNTIME', '-sMODULARIZE', '-sENVIRONMENT=web,worker', '-o', outfile]) self.run_process(shared.get_npm_cmd('webpack') + ['--mode=development', '--no-devtool']) - shutil.copyfile('webpack/src/hello.wasm', 'webpack/dist/hello.wasm') + shutil.copy('webpack/src/hello.wasm', 'webpack/dist/') self.run_browser('webpack/dist/index.html', '/report_result?exit:0') def test_fetch_polyfill_preload(self): diff --git a/test/test_core.py b/test/test_core.py index c2ce1129731f..a040f44a7832 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -556,7 +556,7 @@ def test_core_types(self): def test_cube2md5(self): self.emcc_args += ['--embed-file', 'cube2md5.txt'] - shutil.copyfile(test_file('cube2md5.txt'), 'cube2md5.txt') + shutil.copy(test_file('cube2md5.txt'), '.') self.do_run_in_out_file_test('cube2md5.cpp', assert_returncode=NON_ZERO) @also_with_standalone_wasm() @@ -1155,7 +1155,7 @@ def test_exceptions_allowed(self): size = os.path.getsize('test_exceptions_allowed.js') if self.is_wasm(): size += os.path.getsize('test_exceptions_allowed.wasm') - shutil.copyfile('test_exceptions_allowed.js', 'orig.js') + shutil.copy('test_exceptions_allowed.js', 'orig.js') # check that an empty allow list works properly (as in, same as exceptions disabled) @@ -1164,21 +1164,21 @@ def test_exceptions_allowed(self): empty_size = os.path.getsize('test_exceptions_allowed.js') if self.is_wasm(): empty_size += os.path.getsize('test_exceptions_allowed.wasm') - shutil.copyfile('test_exceptions_allowed.js', 'empty.js') + shutil.copy('test_exceptions_allowed.js', 'empty.js') self.set_setting('EXCEPTION_CATCHING_ALLOWED', ['fake']) self.do_run_in_out_file_test('core/test_exceptions_allowed.cpp', out_suffix='_empty', assert_returncode=NON_ZERO) fake_size = os.path.getsize('test_exceptions_allowed.js') if self.is_wasm(): fake_size += os.path.getsize('test_exceptions_allowed.wasm') - shutil.copyfile('test_exceptions_allowed.js', 'fake.js') + shutil.copy('test_exceptions_allowed.js', 'fake.js') self.clear_setting('EXCEPTION_CATCHING_ALLOWED') self.do_run_in_out_file_test('core/test_exceptions_allowed.cpp', out_suffix='_empty', assert_returncode=NON_ZERO) disabled_size = os.path.getsize('test_exceptions_allowed.js') if self.is_wasm(): disabled_size += os.path.getsize('test_exceptions_allowed.wasm') - shutil.copyfile('test_exceptions_allowed.js', 'disabled.js') + shutil.copy('test_exceptions_allowed.js', 'disabled.js') print('size: %d' % size) print('empty_size: %d' % empty_size) @@ -2595,7 +2595,7 @@ def test_pthread_tls_dylink(self): self.do_run_in_out_file_test('pthread/test_pthread_tls_dylink.c') def test_pthread_run_script(self): - shutil.copyfile(test_file('pthread/foo.js'), 'foo.js') + shutil.copy(test_file('pthread/foo.js'), '.') self.do_runf('pthread/test_pthread_run_script.c') # Run the test again with PROXY_TO_PTHREAD @@ -3234,7 +3234,7 @@ def test_dlfcn_alignment_and_zeroing(self): self.build_dlfcn_lib('liblib.c') for i in range(10): curr = '%d.so' % i - shutil.copyfile('liblib.so', curr) + shutil.copy('liblib.so', curr) self.prep_dlfcn_main() self.set_setting('INITIAL_MEMORY', '128mb') @@ -6701,7 +6701,7 @@ def test_freetype(self): )) # Not needed for js, but useful for debugging - shutil.copyfile(test_file('freetype/LiberationSansBold.ttf'), 'font.ttf') + shutil.copy(test_file('freetype/LiberationSansBold.ttf'), 'font.ttf') ftlib = self.get_freetype_library() # Main @@ -6809,7 +6809,7 @@ def test_poppler(self): # See https://github.com/emscripten-core/emscripten/issues/20757 self.emcc_args.append('-Wno-deprecated-declarations') poppler = self.get_poppler_library() - shutil.copyfile(test_file('poppler/paper.pdf'), 'paper.pdf') + shutil.copy(test_file('poppler/paper.pdf'), '.') create_file('pre.js', ''' Module.preRun = () => { @@ -7804,7 +7804,7 @@ def test_dwarf(self): js_filename = 'a.out.js' wasm_filename = 'a.out.wasm' - shutil.copyfile(test_file('core/test_dwarf.c'), 'test_dwarf.c') + shutil.copy(test_file('core/test_dwarf.c'), '.') self.emcc('test_dwarf.c', output_filename=js_filename) @@ -8391,7 +8391,7 @@ def break_wasm(name): break if wat is None: # $foo_end is not present in the wasm, nothing to break - shutil.copyfile(name, name + '.orig') + shutil.copy(name, name + '.orig') return False create_file('wat.wat', wat) shutil.move(name, name + '.orig') @@ -8416,8 +8416,8 @@ def verify_broken(args): verify_broken(['0']) # restore - shutil.copyfile('emscripten_lazy_load_code.wasm.orig', 'emscripten_lazy_load_code.wasm') - shutil.copyfile('emscripten_lazy_load_code.wasm.lazy.wasm.orig', 'emscripten_lazy_load_code.wasm.lazy.wasm') + shutil.copy('emscripten_lazy_load_code.wasm.orig', 'emscripten_lazy_load_code.wasm') + shutil.copy('emscripten_lazy_load_code.wasm.lazy.wasm.orig', 'emscripten_lazy_load_code.wasm.lazy.wasm') verify_working(['0']) if conditional: @@ -9327,7 +9327,7 @@ def test_pthread_dlopen_many(self): self.emcc_args += ['-Wno-experimental', '-pthread'] self.build_dlfcn_lib(test_file('core/pthread/test_pthread_dlopen_side.c')) for i in range(nthreads): - shutil.copyfile('liblib.so', f'liblib{i}.so') + shutil.copy('liblib.so', f'liblib{i}.so') self.prep_dlfcn_main() self.set_setting('EXIT_RUNTIME') diff --git a/test/test_interactive.py b/test/test_interactive.py index 5c53b37e2342..ea2467548543 100644 --- a/test/test_interactive.py +++ b/test/test_interactive.py @@ -55,10 +55,10 @@ def test_sdl2_togglefullscreen(self): self.btest_exit('browser/test_sdl_togglefullscreen.c', args=['-sUSE_SDL=2']) def test_sdl_audio(self): - shutil.copyfile(test_file('sounds/alarmvictory_1.ogg'), self.in_dir('sound.ogg')) - shutil.copyfile(test_file('sounds/alarmcreatemiltaryfoot_1.wav'), self.in_dir('sound2.wav')) - shutil.copyfile(test_file('sounds/noise.ogg'), self.in_dir('noise.ogg')) - shutil.copyfile(test_file('sounds/the_entertainer.ogg'), self.in_dir('the_entertainer.ogg')) + shutil.copy(test_file('sounds/alarmvictory_1.ogg'), 'sound.ogg') + shutil.copy(test_file('sounds/alarmcreatemiltaryfoot_1.wav'), 'sound2.wav') + shutil.copy(test_file('sounds/noise.ogg'), 'noise.ogg') + shutil.copy(test_file('sounds/the_entertainer.ogg'), 'the_entertainer.ogg') create_file('bad.ogg', 'I claim to be audio, but am lying') # use closure to check for a possible bug with closure minifying away newer Audio() attributes @@ -70,7 +70,7 @@ def test_sdl_audio(self): # depended on fragile SDL1/SDL2 mixing, which stopped working with # 7a5744d754e00bec4422405a1a94f60b8e53c8fc (which just uncovered # the existing problem) - # self.run_process([EMCC, '-O1', '--closure', '0', '--minify=0', self.in_dir('sdl_audio.c'), '--preload-file', 'sound.ogg', '--preload-file', 'sound2.wav', '--embed-file', 'the_entertainer.ogg', '--preload-file', 'noise.ogg', '--preload-file', 'bad.ogg', '-o', 'page.html', '-sEXPORTED_FUNCTIONS=[_main,_play,_play2', '-sUSE_SDL=2', '-DUSE_SDL2']).communicate() + # self.run_process([EMCC, '-O1', '--closure', '0', '--minify=0', 'sdl_audio.c', '--preload-file', 'sound.ogg', '--preload-file', 'sound2.wav', '--embed-file', 'the_entertainer.ogg', '--preload-file', 'noise.ogg', '--preload-file', 'bad.ogg', '-o', 'page.html', '-sEXPORTED_FUNCTIONS=[_main,_play,_play2', '-sUSE_SDL=2', '-DUSE_SDL2']).communicate() # self.run_browser('page.html', '', '/report_result?1') @parameterized({ @@ -78,7 +78,7 @@ def test_sdl_audio(self): 'wasmfs': (['-sWASMFS'],), }) def test_sdl_audio_mix_channels(self, args): - shutil.copyfile(test_file('sounds/noise.ogg'), self.in_dir('sound.ogg')) + shutil.copy(test_file('sounds/noise.ogg'), 'sound.ogg') self.btest_exit('test_sdl_audio_mix_channels.c', args=['-O2', '--minify=0', '--preload-file', 'sound.ogg'] + args) @@ -87,14 +87,14 @@ def test_sdl_audio_mix_channels(self, args): 'wasmfs': (['-sWASMFS'],), }) def test_sdl_audio_mix(self, args): - shutil.copyfile(test_file('sounds/pluck.ogg'), self.in_dir('sound.ogg')) - shutil.copyfile(test_file('sounds/the_entertainer.ogg'), self.in_dir('music.ogg')) - shutil.copyfile(test_file('sounds/noise.ogg'), self.in_dir('noise.ogg')) + shutil.copy(test_file('sounds/pluck.ogg'), 'sound.ogg') + shutil.copy(test_file('sounds/the_entertainer.ogg'), 'music.ogg') + shutil.copy(test_file('sounds/noise.ogg'), 'noise.ogg') self.btest_exit('test_sdl_audio_mix.c', args=['-O2', '--minify=0', '--preload-file', 'sound.ogg', '--preload-file', 'music.ogg', '--preload-file', 'noise.ogg'] + args) def test_sdl_audio_panning(self): - shutil.copyfile(test_file('sounds/the_entertainer.wav'), self.in_dir('the_entertainer.wav')) + shutil.copy(test_file('sounds/the_entertainer.wav'), '.') # use closure to check for a possible bug with closure minifying away newer Audio() attributes self.btest_exit('test_sdl_audio_panning.c', args=['-O2', '--closure=1', '--minify=0', '--preload-file', 'the_entertainer.wav', '-sEXPORTED_FUNCTIONS=_main,_play']) @@ -104,7 +104,7 @@ def test_sdl_audio_beeps(self): self.btest_exit('test_sdl_audio_beep.cpp', args=['-O2', '--closure=1', '--minify=0', '-sDISABLE_EXCEPTION_CATCHING=0', '-o', 'page.html']) def test_sdl2_mixer_wav(self): - shutil.copyfile(test_file('sounds/the_entertainer.wav'), 'sound.wav') + shutil.copy(test_file('sounds/the_entertainer.wav'), 'sound.wav') self.btest_exit('browser/test_sdl2_mixer_wav.c', args=[ '-O2', '-sUSE_SDL=2', @@ -119,7 +119,7 @@ def test_sdl2_mixer_wav(self): 'mp3': (['mp3'], 'MIX_INIT_MP3', 'pudinha.mp3'), }) def test_sdl2_mixer_music(self, formats, flags, music_name): - shutil.copyfile(test_file('sounds', music_name), music_name) + shutil.copy(test_file('sounds', music_name), '.') self.btest('browser/test_sdl2_mixer_music.c', expected='exit:0', args=[ '-O2', '--minify=0', @@ -142,7 +142,7 @@ def test_sdl2_audio_beeps(self): 'proxy_to_pthread': (['-sPROXY_TO_PTHREAD', '-pthread'],), }) def test_openal_playback(self, args): - shutil.copyfile(test_file('sounds/audio.wav'), self.in_dir('audio.wav')) + shutil.copy(test_file('sounds/audio.wav'), '.') self.btest('openal/test_openal_playback.c', '1', args=['-O2', '--preload-file', 'audio.wav'] + args) def test_openal_buffers(self): diff --git a/test/test_other.py b/test/test_other.py index 5969606f258a..5a7d2d9ef841 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -1166,7 +1166,7 @@ def test_odd_suffixes(self): for suffix in ('CPP', 'c++', 'C++', 'cxx', 'CXX', 'cc', 'CC'): self.clear() print(suffix) - shutil.copyfile(test_file('hello_world.c'), 'test.' + suffix) + shutil.copy(test_file('hello_world.c'), 'test.' + suffix) self.do_runf('test.' + suffix, 'hello, world!') for suffix in ('lo'): @@ -1743,10 +1743,8 @@ def test_ungetc_fscanf(self): self.assertContained('zyx', self.run_process(config.JS_ENGINES[0] + ['a.out.js'], stdout=PIPE, stderr=PIPE).stdout) def test_abspaths(self): - # Includes with absolute paths are generally dangerous, things like -I/usr/.. will get to system local headers, not our portable ones. - - shutil.copyfile(test_file('hello_world.c'), 'main.c') - + # Includes with absolute paths are generally dangerous, things like -I/usr/.. will get to system + # local headers, not our portable ones. for args, expected in [(['-I/usr/something', '-Wwarn-absolute-paths'], True), (['-L/usr/something', '-Wwarn-absolute-paths'], True), (['-I/usr/something'], False), @@ -1757,7 +1755,7 @@ def test_abspaths(self): (['-Lsubdir/something', '-Wwarn-absolute-paths'], False), ([], False)]: print(args, expected) - proc = self.run_process([EMCC, 'main.c'] + args, stderr=PIPE) + proc = self.run_process([EMCC, test_file('hello_world.c')] + args, stderr=PIPE) WARNING = 'encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript)' self.assertContainedIf(WARNING, proc.stderr, expected) @@ -2118,7 +2116,7 @@ def test(link_flags, lib_suffix): self.assertContained('*hello from lib\n|hello from lib|\n*\n', self.run_js('a.out.js')) test(['-lfile'], '') # -l, auto detection from library path - test([self.in_dir('libdir', 'libfile.so.3.1.4.1.5.9')], '.3.1.4.1.5.9') # handle libX.so.1.2.3 as well + test([self.in_dir('libdir/libfile.so.3.1.4.1.5.9')], '.3.1.4.1.5.9') # handle libX.so.1.2.3 as well @node_pthreads def test_dylink_pthread_static_data(self): @@ -2417,7 +2415,7 @@ def test_sdl2_gfx_linkable(self): @requires_network def test_libpng(self): - shutil.copyfile(test_file('third_party/libpng/pngtest.png'), 'pngtest.png') + shutil.copy(test_file('third_party/libpng/pngtest.png'), '.') self.do_runf('third_party/libpng/pngtest.c', 'libpng passes test', emcc_args=['--embed-file', 'pngtest.png', '-sUSE_LIBPNG']) self.do_runf('third_party/libpng/pngtest.c', 'libpng passes test', @@ -2426,7 +2424,7 @@ def test_libpng(self): @node_pthreads @requires_network def test_libpng_with_pthreads(self): - shutil.copyfile(test_file('third_party/libpng/pngtest.png'), 'pngtest.png') + shutil.copy(test_file('third_party/libpng/pngtest.png'), '.') self.do_runf('third_party/libpng/pngtest.c', 'libpng passes test', emcc_args=['--embed-file', 'pngtest.png', '-sUSE_LIBPNG', '-pthread']) @@ -2434,7 +2432,7 @@ def test_libpng_with_pthreads(self): def test_giflib(self): # giftext.c contains a sprintf warning self.emcc_args += ['-Wno-fortify-source'] - shutil.copyfile(test_file('third_party/giflib/treescap.gif'), 'treescap.gif') + shutil.copy(test_file('third_party/giflib/treescap.gif'), '.') self.do_runf('third_party/giflib/giftext.c', 'GIF file terminated normally', emcc_args=['--embed-file', 'treescap.gif', '-sUSE_GIFLIB'], @@ -2451,7 +2449,7 @@ def test_giflib(self): @requires_network def test_libjpeg(self): - shutil.copyfile(test_file('screenshot.jpg'), 'screenshot.jpg') + shutil.copy(test_file('screenshot.jpg'), '.') self.do_runf('jpeg_test.c', 'Image is 600 by 450 with 3 components', emcc_args=['--embed-file', 'screenshot.jpg', '-sUSE_LIBJPEG'], args=['screenshot.jpg']) @@ -2896,7 +2894,7 @@ def test_js_optimizer_py(self, name, passes): # run the js optimizer python script. this differs from test_js_optimizer # which runs the internal js optimizer JS script directly (which the python # script calls) - shutil.copyfile(test_file('js_optimizer', name + '.js'), name + '.js') + shutil.copy(test_file('js_optimizer', name + '.js'), '.') self.run_process([PYTHON, path_from_root('tools/js_optimizer.py'), name + '.js'] + passes) actual = read_file(name + '.js.jsopt.js') self.assertFileContents(test_file('js_optimizer', name + '-output.js'), actual) @@ -3748,7 +3746,7 @@ def test_file_packager_modularize(self): self.assertContained('|hello world|', result) def test_sdl_headless(self): - shutil.copyfile(test_file('screenshot.png'), 'example.png') + shutil.copy(test_file('screenshot.png'), 'example.png') self.do_other_test('test_sdl_headless.c', emcc_args=['-sHEADLESS']) def test_preprocess(self): @@ -3888,7 +3886,7 @@ def test_module_exports_with_closure(self): # Check that main.js (which requires test.js) completes successfully when run in node.js # in order to check that the exports are indeed functioning correctly. - shutil.copyfile(test_file('module_exports/main.js'), 'main.js') + shutil.copy(test_file('module_exports/main.js'), '.') self.assertContained('bufferTest finished', self.run_js('main.js')) # Delete test.js again and check it's gone. @@ -4297,10 +4295,10 @@ def test_proxyfs(self): '-sEXPORTED_RUNTIME_METHODS=ccall,cwrap,FS,PROXYFS', '-lproxyfs.js', '-sWASM_ASYNC_COMPILATION=0']) - # Following shutil.copyfile just prevent 'require' of node.js from caching js-object. + # Following shutil.copy just prevent 'require' of node.js from caching js-object. # See https://nodejs.org/api/modules.html - shutil.copyfile('proxyfs_test.js', 'proxyfs_test1.js') - shutil.copyfile('proxyfs_test.js', 'proxyfs_test2.js') + shutil.copy('proxyfs_test.js', 'proxyfs_test1.js') + shutil.copy('proxyfs_test.js', 'proxyfs_test2.js') out = self.run_js('proxyfs_test_main.js') section = "child m1 reads and writes local file." self.assertContained(section + ":m1 read embed:test", out) @@ -4369,21 +4367,21 @@ def test_dependency_file(self): self.assertContained('test.h', tail) def test_dependency_file_2(self): - shutil.copyfile(test_file('hello_world.c'), 'a.c') + shutil.copy(test_file('hello_world.c'), 'a.c') self.run_process([EMCC, 'a.c', '-MMD', '-MF', 'test.d', '-c']) self.assertContained('a.o: a.c\n', read_file('test.d')) - shutil.copyfile(test_file('hello_world.c'), 'a.c') + shutil.copy(test_file('hello_world.c'), 'a.c') self.run_process([EMCC, 'a.c', '-MMD', '-MF', 'test2.d', '-c', '-o', 'test.o']) self.assertContained('test.o: a.c\n', read_file('test2.d')) - shutil.copyfile(test_file('hello_world.c'), 'a.c') + shutil.copy(test_file('hello_world.c'), 'a.c') ensure_dir('obj') self.run_process([EMCC, 'a.c', '-MMD', '-MF', 'test3.d', '-c', '-o', 'obj/test.o']) self.assertContained('obj/test.o: a.c\n', read_file('test3.d')) def test_compilation_database(self): - shutil.copyfile(test_file('hello_world.c'), 'a.c') + shutil.copy(test_file('hello_world.c'), 'a.c') self.run_process([EMCC, 'a.c', '-MJ', 'hello.json', '-c', '-o', 'test.o']) self.assertContained('"file": "a.c", "output": "test.o"', read_file('hello.json')) @@ -6424,7 +6422,7 @@ def test_cleanup_os(self): def test(args, be_clean): print(args) self.clear() - shutil.copyfile(test_file('hello_world.c'), 'a.c') + shutil.copy(test_file('hello_world.c'), 'a.c') create_file('b.c', ' ') self.run_process([EMCC, 'a.c', 'b.c'] + args) clutter = glob.glob('*.o') @@ -8115,8 +8113,8 @@ def test(p1, p2, p3, last, expected): create_file('src.cpp', src) self.run_process([EMXX, 'src.cpp', '-O2', '-sEVAL_CTORS', '-profiling-funcs']) self.assertContained('total is %s.' % hex(expected), self.run_js('a.out.js')) - shutil.copyfile('a.out.js', 'x' + hex(expected) + '.js') - shutil.copyfile('a.out.wasm', 'x' + hex(expected) + '.wasm') + shutil.copy('a.out.js', 'x' + hex(expected) + '.js') + shutil.copy('a.out.wasm', 'x' + hex(expected) + '.wasm') return os.path.getsize('a.out.wasm') print('no bad ctor') @@ -9612,7 +9610,7 @@ def test_closure_webgpu(self): def test_closure_externs(self): # Test with relocate path to the externs file to ensure that incoming relative paths # are translated correctly (Since closure runs with a different CWD) - shutil.copyfile(test_file('test_closure_externs.js'), 'local_externs.js') + shutil.copy(test_file('test_closure_externs.js'), 'local_externs.js') test_cases = ( ['--closure-args', '--externs "local_externs.js"'], ['--closure-args', '--externs=local_externs.js'], @@ -9627,7 +9625,7 @@ def test_closure_externs(self): # Tests that it is possible to enable the Closure compiler via --closure=1 even if any of the input files reside in a path with unicode characters. def test_closure_cmdline_utf8_chars(self): test = "☃ äö Ć € ' 🦠.c" - shutil.copyfile(test_file('hello_world.c'), test) + shutil.copy(test_file('hello_world.c'), test) externs = '💩' + test create_file(externs, '') self.run_process([EMCC, test, '--closure=1', '--closure-args', '--externs "' + externs + '"']) @@ -9955,7 +9953,7 @@ def test_check_sourcemapurl_default(self, *args): def test_wasm_sourcemap(self): # The no_main.c will be read (from relative location) due to speficied "-s" - shutil.copyfile(test_file('other/wasm_sourcemap/no_main.c'), 'no_main.c') + shutil.copy(test_file('other/wasm_sourcemap/no_main.c'), '.') wasm_map_cmd = [PYTHON, path_from_root('tools/wasm-sourcemap.py'), '--sources', '--prefix', '=wasm-src://', '--load-prefix', '/emscripten/test/other/wasm_sourcemap=.', @@ -9993,7 +9991,7 @@ def test(infile, source_map_added_dir=''): if source_map_added_dir: expected_source_map_path = source_map_added_dir + '/' + expected_source_map_path print(infile, expected_source_map_path) - shutil.copyfile(test_file('hello_123.c'), infile) + shutil.copy(test_file('hello_123.c'), infile) infiles = [ infile, os.path.abspath(infile), @@ -14800,7 +14798,7 @@ def test_no_minify_and_later_closure(self): temp = building.closure_compiler('a.out.js', advanced=True, extra_closure_args=['--formatting', 'PRETTY_PRINT']) - shutil.copyfile(temp, 'closured.js') + shutil.copy(temp, 'closured.js') self.assertContained('hello, world!', self.run_js('closured.js')) def test_table_base(self):