File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,7 +92,10 @@ if(ENABLE_SANITIZERS)
9292 set (SANITIZERS "address,undefined" )
9393 # Check for Clang since vptr and fdsan are Clang-specific
9494 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
95- list (APPEND SANITIZERS "vptr" )
95+ # vptr is not supported on Windows.
96+ if (NOT WIN32 )
97+ list (APPEND SANITIZERS "vptr" )
98+ endif ()
9699 # FDSan only works on Android builds with Clang
97100 if (ANDROID )
98101 list (APPEND SANITIZERS "fdsan" )
Original file line number Diff line number Diff line change @@ -46,6 +46,10 @@ endif()
4646add_executable (UnitTests ${SOURCES} ${SCRIPTS} ${TYPE_SCRIPTS} ${ASSETS} )
4747target_compile_definitions (UnitTests PRIVATE JSRUNTIMEHOST_PLATFORM= "${JSRUNTIMEHOST_PLATFORM} " )
4848
49+ if (ENABLE_SANITIZERS)
50+ target_compile_definitions (UnitTests PRIVATE JSRUNTIMEHOST_SANITIZERS_ENABLED=1 )
51+ endif ()
52+
4953target_link_libraries (UnitTests
5054 PRIVATE AppRuntime
5155 PRIVATE Console
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ Mocha.reporter('spec');
77
88declare const hostPlatform : string ;
99declare const setExitCode : ( code : number ) => void ;
10+ declare const sanitizersEnabled : boolean ;
1011
1112
1213describe ( "AbortController" , function ( ) {
@@ -1234,11 +1235,11 @@ describe("Performance", function () {
12341235 it ( "should measure elapsed time accurately" , function ( done ) {
12351236 const start = performance . now ( ) ;
12361237 const delay = 50 ;
1238+ const tolerance = sanitizersEnabled ? 500 : 100 ;
12371239 setTimeout ( ( ) => {
12381240 const elapsed = performance . now ( ) - start ;
1239- // Allow some tolerance (elapsed should be at least the delay, but could be slightly more)
12401241 expect ( elapsed ) . to . be . at . least ( delay - 5 ) ;
1241- expect ( elapsed ) . to . be . lessThan ( delay + 100 ) ; // generous upper bound
1242+ expect ( elapsed ) . to . be . lessThan ( delay + tolerance ) ;
12421243 done ( ) ;
12431244 } , delay ) ;
12441245 } ) ;
Original file line number Diff line number Diff line change @@ -80,6 +80,12 @@ TEST(JavaScript, All)
8080 env.Global ().Set (" setExitCode" , setExitCodeCallback);
8181
8282 env.Global ().Set (" hostPlatform" , Napi::Value::From (env, JSRUNTIMEHOST_PLATFORM));
83+
84+ #ifdef JSRUNTIMEHOST_SANITIZERS_ENABLED
85+ env.Global ().Set (" sanitizersEnabled" , Napi::Value::From (env, true ));
86+ #else
87+ env.Global ().Set (" sanitizersEnabled" , Napi::Value::From (env, false ));
88+ #endif
8389 });
8490
8591 Babylon::ScriptLoader loader{runtime};
You can’t perform that action at this time.
0 commit comments