21
21
from tools .shared import EXPECTED_LLVM_VERSION , Cache
22
22
from tools import shared , system_libs , utils
23
23
24
- SANITY_FILE = shared .Cache .get_path ('sanity.txt' , root = True )
24
+ SANITY_FILE = shared .Cache .get_path ('sanity.txt' )
25
25
commands = [[EMCC ], [PYTHON , path_from_root ('tests' , 'runner.py' ), 'blahblah' ]]
26
26
27
27
@@ -418,24 +418,22 @@ def test_emcc_caching(self):
418
418
419
419
# Building a file that *does* need something *should* trigger cache
420
420
# generation, but only the first time
421
- libname = 'libc++'
421
+ libname = Cache . get_lib_name ( 'libc++.a' )
422
422
for i in range (3 ):
423
423
print (i )
424
424
self .clear ()
425
425
output = self .do ([EMCC , '-O' + str (i ), path_from_root ('tests' , 'hello_libcxx.cpp' ), '-s' , 'DISABLE_EXCEPTION_CATCHING=0' ])
426
426
print ('\n \n \n ' , output )
427
- self .assertContainedIf (BUILDING_MESSAGE . replace ( 'X' , libname ) , output , i == 0 )
427
+ self .assertContainedIf (BUILDING_MESSAGE % libname , output , i == 0 )
428
428
self .assertContained ('hello, world!' , self .run_js ('a.out.js' ))
429
429
self .assertExists (Cache .dirname )
430
- full_libname = libname + '.bc' if libname != 'libc++' else libname + '.a'
431
- self .assertExists (os .path .join (Cache .dirname , full_libname ))
430
+ self .assertExists (os .path .join (Cache .dirname , libname ))
432
431
433
432
def test_cache_clearing_manual (self ):
434
433
# Manual cache clearing
435
434
restore_and_set_up ()
436
435
self .ensure_cache ()
437
436
self .assertTrue (os .path .exists (Cache .dirname ))
438
- self .assertTrue (os .path .exists (Cache .root_dirname ))
439
437
output = self .do ([EMCC , '--clear-cache' ])
440
438
self .assertIn ('clearing cache' , output )
441
439
self .assertIn (SANITY_MESSAGE , output )
@@ -459,12 +457,10 @@ def test_FROZEN_CACHE(self):
459
457
self .erase_cache ()
460
458
self .ensure_cache ()
461
459
self .assertTrue (os .path .exists (Cache .dirname ))
462
- self .assertTrue (os .path .exists (Cache .root_dirname ))
463
460
# changing config file should not clear cache
464
461
add_to_config ('FROZEN_CACHE = True' )
465
462
self .do ([EMCC ])
466
463
self .assertTrue (os .path .exists (Cache .dirname ))
467
- self .assertTrue (os .path .exists (Cache .root_dirname ))
468
464
# building libraries is disallowed
469
465
output = self .do ([EMBUILDER , 'build' , 'libemmalloc' ])
470
466
self .assertIn ('FROZEN_CACHE disallows building system libs' , output )
@@ -483,6 +479,7 @@ def test_emcc_multiprocess_cache_access(self):
483
479
}
484
480
''' )
485
481
cache_dir_name = self .in_dir ('test_cache' )
482
+ libname = Cache .get_lib_name ('libc.a' )
486
483
with env_modify ({'EM_CACHE' : cache_dir_name }):
487
484
tasks = []
488
485
num_times_libc_was_built = 0
@@ -491,13 +488,13 @@ def test_emcc_multiprocess_cache_access(self):
491
488
tasks += [p ]
492
489
for p in tasks :
493
490
print ('stdout:\n ' , p .stdout )
494
- if 'generating system library: libc' in p .stdout :
491
+ if 'generating system library: ' + libname in p .stdout :
495
492
num_times_libc_was_built += 1
496
493
497
494
# The cache directory must exist after the build
498
495
self .assertTrue (os .path .exists (cache_dir_name ))
499
496
# The cache directory must contain a built libc
500
- self .assertTrue (os .path .exists (os .path .join (cache_dir_name , 'wasm' , 'libc.a' )))
497
+ self .assertTrue (os .path .exists (os .path .join (cache_dir_name , libname )))
501
498
# Exactly one child process should have triggered libc build!
502
499
self .assertEqual (num_times_libc_was_built , 1 )
503
500
@@ -531,12 +528,11 @@ def test_emcc_ports(self):
531
528
restore_and_set_up ()
532
529
533
530
# listing ports
534
-
535
531
out = self .do ([EMCC , '--show-ports' ])
536
- assert 'Available ports:' in out , out
537
- assert 'SDL2' in out , out
538
- assert 'SDL2_image' in out , out
539
- assert 'SDL2_net' in out , out
532
+ self . assertContained ( 'Available ports:' , out )
533
+ self . assertContained ( 'SDL2' , out )
534
+ self . assertContained ( 'SDL2_image' , out )
535
+ self . assertContained ( 'SDL2_net' , out )
540
536
541
537
# using ports
542
538
RETRIEVING_MESSAGE = 'retrieving port'
@@ -551,27 +547,27 @@ def test_emcc_ports(self):
551
547
try_delete (PORTS_DIR )
552
548
else :
553
549
self .do ([EMCC , '--clear-ports' ])
554
- assert not os . path . exists (PORTS_DIR )
550
+ self . assertNotExists (PORTS_DIR )
555
551
556
552
# Building a file that doesn't need ports should not trigger anything
557
553
output = self .do ([EMCC , path_from_root ('tests' , 'hello_world_sdl.cpp' )])
558
554
assert RETRIEVING_MESSAGE not in output , output
559
555
assert BUILDING_MESSAGE not in output
560
556
print ('no' , output )
561
- assert not os . path . exists (PORTS_DIR )
557
+ self . assertNotExists (PORTS_DIR )
562
558
563
559
def first_use ():
564
560
output = self .do ([EMCC , path_from_root ('tests' , 'hello_world_sdl.cpp' ), '-s' , 'USE_SDL=2' ])
565
- assert RETRIEVING_MESSAGE in output , output
566
- assert BUILDING_MESSAGE in output , output
561
+ self . assertContained ( RETRIEVING_MESSAGE , output )
562
+ self . assertContained ( BUILDING_MESSAGE , output )
567
563
self .assertExists (PORTS_DIR )
568
564
print ('yes' , output )
569
565
570
566
def second_use ():
571
567
# Using it again avoids retrieve and build
572
568
output = self .do ([EMCC , path_from_root ('tests' , 'hello_world_sdl.cpp' ), '-s' , 'USE_SDL=2' ])
573
- assert RETRIEVING_MESSAGE not in output , output
574
- assert BUILDING_MESSAGE not in output , output
569
+ self . assertNotContained ( RETRIEVING_MESSAGE , output )
570
+ self . assertNotContained ( BUILDING_MESSAGE , output )
575
571
576
572
# Building a file that need a port does trigger stuff
577
573
first_use ()
0 commit comments