Skip to content

Commit 0706d4e

Browse files
authored
tests: Make use of self.in_dir helper function everywhere. NFC (#17501)
1 parent dca2358 commit 0706d4e

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

tests/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ def assertBinaryEqual(self, file1, file2):
898898
library_cache = {}
899899

900900
def get_build_dir(self):
901-
ret = os.path.join(self.get_dir(), 'building')
901+
ret = self.in_dir('building')
902902
ensure_dir(ret)
903903
return ret
904904

@@ -1551,7 +1551,7 @@ def reftest(self, expected, manually_trigger=False):
15511551
# make sure the pngs used here have no color correction, using e.g.
15521552
# pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB infile outfile
15531553
basename = os.path.basename(expected)
1554-
shutil.copyfile(expected, os.path.join(self.get_dir(), basename))
1554+
shutil.copyfile(expected, self.in_dir(basename))
15551555
reporting = read_file(test_file('browser_reporting.js'))
15561556
write_file('reftest.js', '''
15571557
function doReftest() {

tests/test_browser.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,8 +1702,6 @@ def test_chunked_synchronous_xhr(self):
17021702
Module["print"] = function(s) { self.postMessage({channel: "stdout", line: s}); };
17031703
Module["printErr"] = function(s) { self.postMessage({channel: "stderr", char: s, trace: ((doTrace && s === 10) ? new Error().stack : null)}); doTrace = false; };
17041704
""")
1705-
# vs. os.path.join(self.get_dir(), filename)
1706-
# vs. test_file('hello_world_gles.c')
17071705
self.compile_btest([test_file('checksummer.c'), '-g', '-sSMALL_XHR_CHUNKS', '-o', worker_filename,
17081706
'--pre-js', 'worker_prejs.js'])
17091707
chunkSize = 1024

tests/test_interactive.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ def test_sdl2_togglefullscreen(self):
5656
self.btest_exit('sdl_togglefullscreen.c', args=['-sUSE_SDL=2'])
5757

5858
def test_sdl_audio(self):
59-
shutil.copyfile(test_file('sounds', 'alarmvictory_1.ogg'), os.path.join(self.get_dir(), 'sound.ogg'))
60-
shutil.copyfile(test_file('sounds', 'alarmcreatemiltaryfoot_1.wav'), os.path.join(self.get_dir(), 'sound2.wav'))
61-
shutil.copyfile(test_file('sounds', 'noise.ogg'), os.path.join(self.get_dir(), 'noise.ogg'))
62-
shutil.copyfile(test_file('sounds', 'the_entertainer.ogg'), os.path.join(self.get_dir(), 'the_entertainer.ogg'))
63-
open(os.path.join(self.get_dir(), 'bad.ogg'), 'w').write('I claim to be audio, but am lying')
59+
shutil.copyfile(test_file('sounds', 'alarmvictory_1.ogg'), self.in_dir('sound.ogg'))
60+
shutil.copyfile(test_file('sounds', 'alarmcreatemiltaryfoot_1.wav'), self.in_dir('sound2.wav'))
61+
shutil.copyfile(test_file('sounds', 'noise.ogg'), self.in_dir('noise.ogg'))
62+
shutil.copyfile(test_file('sounds', 'the_entertainer.ogg'), self.in_dir('the_entertainer.ogg'))
63+
open(self.in_dir('bad.ogg'), 'w').write('I claim to be audio, but am lying')
6464

6565
# use closure to check for a possible bug with closure minifying away newer Audio() attributes
6666
self.btest_exit(test_file('sdl_audio.c'), args=['--preload-file', 'sound.ogg', '--preload-file', 'sound2.wav', '--embed-file', 'the_entertainer.ogg', '--preload-file', 'noise.ogg', '--preload-file', 'bad.ogg'])
@@ -71,15 +71,15 @@ def test_sdl_audio(self):
7171
# depended on fragile SDL1/SDL2 mixing, which stopped working with
7272
# 7a5744d754e00bec4422405a1a94f60b8e53c8fc (which just uncovered
7373
# the existing problem)
74-
# self.run_process([EMCC, '-O1', '--closure', '0', '--minify=0', os.path.join(self.get_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()
74+
# 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()
7575
# self.run_browser('page.html', '', '/report_result?1')
7676

7777
@parameterized({
7878
'': ([],),
7979
'wasmfs': (['-sWASMFS'],),
8080
})
8181
def test_sdl_audio_mix_channels(self, args):
82-
shutil.copyfile(test_file('sounds', 'noise.ogg'), os.path.join(self.get_dir(), 'sound.ogg'))
82+
shutil.copyfile(test_file('sounds', 'noise.ogg'), self.in_dir('sound.ogg'))
8383

8484
self.btest_exit('sdl_audio_mix_channels.c', args=['-O2', '--minify=0', '--preload-file', 'sound.ogg'] + args)
8585

@@ -88,14 +88,14 @@ def test_sdl_audio_mix_channels(self, args):
8888
'wasmfs': (['-sWASMFS'],),
8989
})
9090
def test_sdl_audio_mix(self, args):
91-
shutil.copyfile(test_file('sounds', 'pluck.ogg'), os.path.join(self.get_dir(), 'sound.ogg'))
92-
shutil.copyfile(test_file('sounds', 'the_entertainer.ogg'), os.path.join(self.get_dir(), 'music.ogg'))
93-
shutil.copyfile(test_file('sounds', 'noise.ogg'), os.path.join(self.get_dir(), 'noise.ogg'))
91+
shutil.copyfile(test_file('sounds', 'pluck.ogg'), self.in_dir('sound.ogg'))
92+
shutil.copyfile(test_file('sounds', 'the_entertainer.ogg'), self.in_dir('music.ogg'))
93+
shutil.copyfile(test_file('sounds', 'noise.ogg'), self.in_dir('noise.ogg'))
9494

9595
self.btest_exit('sdl_audio_mix.c', args=['-O2', '--minify=0', '--preload-file', 'sound.ogg', '--preload-file', 'music.ogg', '--preload-file', 'noise.ogg'] + args)
9696

9797
def test_sdl_audio_panning(self):
98-
shutil.copyfile(test_file('sounds', 'the_entertainer.wav'), os.path.join(self.get_dir(), 'the_entertainer.wav'))
98+
shutil.copyfile(test_file('sounds', 'the_entertainer.wav'), self.in_dir('the_entertainer.wav'))
9999

100100
# use closure to check for a possible bug with closure minifying away newer Audio() attributes
101101
self.btest_exit('sdl_audio_panning.c', args=['-O2', '--closure=1', '--minify=0', '--preload-file', 'the_entertainer.wav', '-sEXPORTED_FUNCTIONS=_main,_play'])
@@ -138,7 +138,7 @@ def test_sdl2_audio_beeps(self):
138138
self.btest_exit(test_file('sdl2_audio_beep.cpp'), args=['-O2', '--closure=1', '--minify=0', '-sDISABLE_EXCEPTION_CATCHING=0', '-sUSE_SDL=2'])
139139

140140
def test_openal_playback(self):
141-
shutil.copyfile(test_file('sounds', 'audio.wav'), os.path.join(self.get_dir(), 'audio.wav'))
141+
shutil.copyfile(test_file('sounds', 'audio.wav'), self.in_dir('audio.wav'))
142142

143143
for args in [[], ['-sUSE_PTHREADS', '-sPROXY_TO_PTHREAD']]:
144144
self.compile_btest(['-O2', test_file('openal_playback.cpp'), '--preload-file', 'audio.wav', '-o', 'page.html'] + args)

tests/test_sockets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,9 @@ def test_posix_proxy_sockets(self):
335335
self.run_process(['cmake', path_from_root('tools/websocket_to_posix_proxy')])
336336
self.run_process(['cmake', '--build', '.'])
337337
if os.name == 'nt': # This is not quite exact, instead of "isWindows()" this should be "If CMake defaults to building with Visual Studio", but there is no good check for that, so assume Windows==VS.
338-
proxy_server = os.path.join(self.get_dir(), 'Debug', 'websocket_to_posix_proxy.exe')
338+
proxy_server = self.in_dir('Debug', 'websocket_to_posix_proxy.exe')
339339
else:
340-
proxy_server = os.path.join(self.get_dir(), 'websocket_to_posix_proxy')
340+
proxy_server = self.in_dir('websocket_to_posix_proxy')
341341

342342
with BackgroundServerProcess([proxy_server, '8080']):
343343
with PythonTcpEchoServerProcess('7777'):

0 commit comments

Comments
 (0)