Skip to content

Commit

Permalink
Merge af2c61a into 293f0d2
Browse files Browse the repository at this point in the history
  • Loading branch information
LanderlYoung committed Dec 7, 2021
2 parents 293f0d2 + af2c61a commit 123c4a1
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
key: build-dependencies-macos
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
build/ScriptXTestLibs
build/googletest-src
Expand Down
25 changes: 18 additions & 7 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- main
paths-ignore:
- 'docs/**'
workflow_dispatch:

jobs:
mac-clang-run:
Expand All @@ -20,13 +21,13 @@ jobs:
backends: [ V8, JavaScriptCore, QuickJs, Lua, Empty ]
build_type:
- Debug
# mac runner seems to be slow and less
# mac runner seems to be slow and rear
# - Release
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
key: build-dependencies-macos
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
build/ScriptXTestLibs
build/googletest-src
Expand Down Expand Up @@ -63,7 +64,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
key: build-dependencies-macos
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
build/ScriptXTestLibs
build/googletest-src
Expand Down Expand Up @@ -113,23 +114,33 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
key: build-dependencies-macos
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
build/ScriptXTestLibs
build/googletest-src
- name: Install Lua Dependencies
if: matrix.backends == 'Lua'
run: |
sudo apt-get install -y liblua5.3-dev
- name: Configure cmake
env:
SCRIPTX_TEST_FORCE_UPDATE_DEPS: ON
SCRIPTX_TEST_BUILD_ONLY: ON
# SCRIPTX_TEST_BUILD_ONLY: ON
run: |
mkdir -p build && cd build
cmake ../test \
-DSCRIPTX_BACKEND=${{ matrix.backends }} \
-DTEST_FLAG_ENABLE_ASAN=ON \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
- name: Compile UnitTests
run: |
cd build
cmake --build . -j $(nproc) --target UnitTests
- name: Run UnitTests
if: matrix.backends != 'Empty'
run: |
cd build
./UnitTests
android-clang-build:
# disable for now
Expand All @@ -149,7 +160,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
key: build-dependencies-macos
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
build/ScriptXTestLibs
build/googletest-src
Expand Down Expand Up @@ -201,7 +212,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
key: build-dependencies-macos
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
build/ScriptXTestLibs
build/googletest-src
Expand Down
13 changes: 12 additions & 1 deletion backend/V8/V8Platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ class MessageQueueTaskRunner : public v8::TaskRunner {

bool IdleTasksEnabled() override { return defaultTaskRunner_->IdleTasksEnabled(); }

void PostNonNestableTask(std::unique_ptr<v8::Task> task) override { PostTask(std::move(task)); }

void PostNonNestableDelayedTask(std::unique_ptr<v8::Task> task,
double delay_in_seconds) override {
PostDelayedTask(std::move(task), delay_in_seconds);
}

bool NonNestableTasksEnabled() const override { return true; }

bool NonNestableDelayedTasksEnabled() const override { return true; }

private:
void schedulePump() {
bool expected = false;
Expand Down Expand Up @@ -160,4 +171,4 @@ bool V8Platform::OnCriticalMemoryPressure(size_t length) {
return defaultPlatform_->OnCriticalMemoryPressure(length);
}

} // namespace script::v8_backend
} // namespace script::v8_backend
11 changes: 8 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ enable_testing()
add_executable(UnitTests)
include(cmake/TestEnv.cmake)

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O3 -flto")

if (TEST_FLAG_ENABLE_ASAN)
# macOS doesn't support -fsanitize=memory
string(APPEND CMAKE_CXX_FLAGS_DEBUG
string(APPEND UNIT_TEST_ASAN_FLAGS
" -fsanitize=address"
" -fsanitize-recover=address"
" -fno-omit-frame-pointer")
Expand All @@ -26,11 +26,15 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (TEST_FLAG_ENABLE_UBSAN)
# UBSan make UnitTests runs very slow
# enable as need
string(APPEND CMAKE_CXX_FLAGS_DEBUG
string(APPEND UNIT_TEST_ASAN_FLAGS
" -fsanitize=undefined"
" -fsanitize-recover=undefined")
endif ()

string(APPEND CMAKE_C_FLAGS ${UNIT_TEST_ASAN_FLAGS})
string(APPEND CMAKE_CXX_FLAGS ${UNIT_TEST_ASAN_FLAGS})
string(APPEND CMAKE_EXE_LINKER ${UNIT_TEST_ASAN_FLAGS})

if (DEVOPS_ENABLE_COVERAGE)
# devops support gcov only
string(APPEND CMAKE_CXX_FLAGS_DEBUG " --coverage -g3")
Expand Down Expand Up @@ -88,6 +92,7 @@ endif ()

include_directories(${DEVOPS_LIBS_INCLUDE})
target_link_libraries(ScriptX ${DEVOPS_LIBS_LIBPATH})
target_compile_definitions(ScriptX PUBLIC ${DEVOPS_LIBS_MARCO})

# if you want to close rtti feature for ScriptX and your project
#target_compile_options(ScriptX PRIVATE -fno-rtti)
Expand Down
35 changes: 13 additions & 22 deletions test/cmake/TestEnv.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,17 @@ if (${SCRIPTX_BACKEND} STREQUAL V8)
set(DEVOPS_LIBS_LIBPATH
"${SCRIPTX_TEST_LIBS}/mac/v8/libv8_monolith.a"
CACHE STRING "" FORCE)

elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# v8 8.8
set(DEVOPS_LIBS_INCLUDE
"${SCRIPTX_TEST_LIBS}/linux64/v8/include"
CACHE STRING "" FORCE)
set(DEVOPS_LIBS_LIBPATH
"${SCRIPTX_TEST_LIBS}/linux64/v8/libv8_monolith.a"
CACHE STRING "" FORCE)
set(DEVOPS_LIBS_MARCO
V8_COMPRESS_POINTERS
CACHE STRING "" FORCE)
elseif (WIN32)
set(DEVOPS_LIBS_INCLUDE
"${SCRIPTX_TEST_LIBS}/win64/v8/include"
Expand Down Expand Up @@ -109,27 +119,8 @@ elseif (${SCRIPTX_BACKEND} STREQUAL JavaScriptCore)
endif ()

elseif (${SCRIPTX_BACKEND} STREQUAL Lua)
if (SCRIPTX_TEST_BUILD_ONLY)
set(DEVOPS_LIBS_INCLUDE
"${SCRIPTX_TEST_LIBS}/mac/lua/include"
CACHE STRING "" FORCE)
elseif (APPLE)
set(DEVOPS_LIBS_INCLUDE
"${SCRIPTX_TEST_LIBS}/mac/lua/include"
CACHE STRING "" FORCE)
set(DEVOPS_LIBS_LIBPATH
"${SCRIPTX_TEST_LIBS}/mac/lua/liblua.a"
CACHE STRING "" FORCE)
elseif (WIN32)
set(DEVOPS_LIBS_INCLUDE
"${SCRIPTX_TEST_LIBS}/win64/lua/include"
CACHE STRING "" FORCE)

set(DEVOPS_LIBS_LIBPATH
"${SCRIPTX_TEST_LIBS}/win64/lua/Lua54.lib"
CACHE STRING "" FORCE)
endif ()

include("${SCRIPTX_TEST_LIBS}/lua/CMakeLists.txt")
set(DEVOPS_LIBS_LIBPATH Lua CACHE STRING "" FORCE)
elseif (${SCRIPTX_BACKEND} STREQUAL WebAssembly)
if ("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE must be passed for emscripten")
Expand Down
2 changes: 1 addition & 1 deletion test/cmake/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (NOT EXISTS ${SCRIPTX_TEST_GOOGLE_TEST})
endif ()
elseif (("${SCRIPTX_TEST_FORCE_UPDATE_DEPS}" STREQUAL ON) OR ("$ENV{SCRIPTX_TEST_FORCE_UPDATE_DEPS}" STREQUAL ON))
message(STATUS "update SCRIPTX_TEST_GOOGLE_TEST ${SCRIPTX_TEST_GOOGLE_TEST}")
execute_process(COMMAND git pull --force --rebase WORKING_DIRECTORY ${SCRIPTX_TEST_GOOGLE_TEST})
execute_process(COMMAND git pull --force --rebase --autostash WORKING_DIRECTORY ${SCRIPTX_TEST_GOOGLE_TEST})
endif ()

# Prevent overriding the parent project's compiler/linker
Expand Down
2 changes: 1 addition & 1 deletion test/cmake/test_libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ if (NOT EXISTS "${SCRIPTX_TEST_LIBS}")
endif ()
elseif (("${SCRIPTX_TEST_FORCE_UPDATE_DEPS}" STREQUAL ON) OR ("$ENV{SCRIPTX_TEST_FORCE_UPDATE_DEPS}" STREQUAL ON))
message(STATUS "update SCRIPTX_TEST_LIBS ${SCRIPTX_TEST_LIBS}")
execute_process(COMMAND git pull --force --rebase WORKING_DIRECTORY ${SCRIPTX_TEST_LIBS})
execute_process(COMMAND git pull --force --rebase --autostash WORKING_DIRECTORY ${SCRIPTX_TEST_LIBS})
endif ()
6 changes: 3 additions & 3 deletions test/src/ExceptionTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ return exceptionStackTraceTest
func.asFunction().call({}, Number::newNumber(0));
FAIL() << "should thrown";
} catch (const Exception& e) {
EXPECT_NE(e.message().find("recursive too deep"), std::string::npos);
EXPECT_NE(e.stacktrace().find("exceptionStackTraceTestThrow"), std::string::npos);
EXPECT_NE(e.stacktrace().find("exceptionStackTraceTest"), std::string::npos);
EXPECT_NE(e.message().find("recursive too deep"), std::string::npos) << e;
EXPECT_NE(e.stacktrace().find("exceptionStackTraceTestThrow"), std::string::npos) << e;
EXPECT_NE(e.stacktrace().find("exceptionStackTraceTest"), std::string::npos) << e;
}
Exception().stacktrace();
std::ostringstream() << Exception();
Expand Down

0 comments on commit 123c4a1

Please sign in to comment.