Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ on:
jobs:
coverage-ubuntu-gcc:
timeout-minutes: 30
# JavaScriptCore requires libicu66 which is only avaliable on ubuntu-20.04
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
backends: [ V8, JavaScriptCore, QuickJs, Lua ]
steps:
- uses: actions/checkout@v4.1.7
- uses: actions/cache@v4.0.2
- uses: actions/cache@v4
with:
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
Expand Down
28 changes: 13 additions & 15 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
# - Release
steps:
- uses: actions/checkout@v4.1.7
- uses: actions/cache@v4.0.2
- uses: actions/cache@v4
with:
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
- Release
steps:
- uses: actions/checkout@v4.1.7
- uses: actions/cache@v4.0.2
- uses: actions/cache@v4
with:
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
Expand Down Expand Up @@ -102,8 +102,7 @@ jobs:

ubuntu-gcc-run:
timeout-minutes: 30
# JavaScriptCore requires libicu66 which is only avaliable on ubuntu-20.04
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
Expand All @@ -113,7 +112,7 @@ jobs:
- Release
steps:
- uses: actions/checkout@v4.1.7
- uses: actions/cache@v4.0.2
- uses: actions/cache@v4
with:
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
Expand All @@ -140,15 +139,15 @@ jobs:

ubuntu-v8-versions-build:
timeout-minutes: 60
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# format index{0 .. index-1}/concurrency
job_split: [ 0/8, 1/8, 2/8, 3/8, 4/8, 5/8, 6/8, 7/8 ]
steps:
- uses: actions/checkout@v4.1.7
- uses: actions/cache@v4.0.2
- uses: actions/cache@v4
with:
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
Expand Down Expand Up @@ -177,7 +176,7 @@ jobs:
- Release
steps:
- uses: actions/checkout@v4.1.7
- uses: actions/cache@v4.0.2
- uses: actions/cache@v4
with:
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
Expand Down Expand Up @@ -206,7 +205,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [ 14.x, 15.x, 16.x, 18.x ] # 19.x
node-version: [ 18.x, 20.x, 22.x ] # 24.x
steps:
- uses: actions/checkout@v4.1.7
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -230,10 +229,10 @@ jobs:
strategy:
fail-fast: false
matrix:
emscripten-version: [ '3.0.0', '3.1.33' ]
emscripten-version: [ '4.0.0', '3.1.33' ]
steps:
- uses: actions/checkout@v4.1.7
- uses: actions/cache@v4.0.2
- uses: actions/cache@v4
with:
key: ScriptX-UnitTests-Depedencies-${{ hashFiles('test/cmake/**') }}
path: |
Expand All @@ -245,9 +244,9 @@ jobs:
version: ${{ matrix.emscripten-version }}
actions-cache-folder: emsdk-cache-${{ matrix.emscripten-version }}
- name: Setup Node.js
uses: actions/setup-node@v4.0.4
uses: actions/setup-node@v4
with:
node-version: '19.3.0' # insteadof '>= 14', use fixed version
node-version: 24 # insteadof '>= 14', use fixed version
- name: Configure Webassembly backend
env:
SCRIPTX_TEST_FORCE_UPDATE_DEPS: ON
Expand All @@ -264,5 +263,4 @@ jobs:
run: |
cd build
# exclude failed tests
# --no-experimental-fetch config from https://github.com/emscripten-core/emscripten/issues/16915
node --no-experimental-fetch UnitTests.js '--gtest_filter=-ThreadPool.*:EngineScopeTest.ExitEngine:EngineScopeTest.TwoThreads:EngineScopeTest.ThreadLocal:MessageQueue.Interrupt:MessageQueue.Shutdown:MessageQueue.ShutdownNow:MessageQueue.FullAndPostInsideLoopQueue:ReferenceTest.WeakGc:ReferenceTest.WeakGc:ReferenceTest.GlobalNotClear:ReferenceTest.GlobalOnEngineDestroy:ReferenceTest.WeakOnEngineDestroy:ReferenceTest.WeakNotClrear:ManagedObjectTest.EngineDispose:ManagedObjectTest.FunctionCallback:PressureTest.All:EngineTest.JsPromiseTest:EngineTest.JsPromiseTest2:ShowCaseTest.SetTimeout'
node UnitTests.js '--gtest_filter=-ThreadPool.*:EngineScopeTest.ExitEngine:EngineScopeTest.TwoThreads:EngineScopeTest.ThreadLocal:MessageQueue.Interrupt:MessageQueue.Shutdown:MessageQueue.ShutdownNow:MessageQueue.FullAndPostInsideLoopQueue:ReferenceTest.WeakGc:ReferenceTest.WeakGc:ReferenceTest.GlobalNotClear:ReferenceTest.GlobalOnEngineDestroy:ReferenceTest.WeakOnEngineDestroy:ReferenceTest.WeakNotClrear:ManagedObjectTest.EngineDispose:ManagedObjectTest.FunctionCallback:PressureTest.All:EngineTest.JsPromiseTest:EngineTest.JsPromiseTest2:ShowCaseTest.SetTimeout'
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.6)

file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/VERSION SCRIPTX_VERSION)

Expand Down
4 changes: 3 additions & 1 deletion backend/JavaScriptCore/JscEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ JSClassRef JscEngine::externalClass_{};

// When we link against high-version library
// but run with a low-version one, macOS/iOS linker just set the undefined symbols to nullptr.
// cast to void* to suppress g++ -Werror=address
// suppress g++ -Werror=address
SCRIPTX_BEGIN_INCLUDE_LIBRARY
bool JscEngine::hasByteBufferAPI_ = reinterpret_cast<void*>(&JSValueGetTypedArrayType) != nullptr;
SCRIPTX_END_INCLUDE_LIBRARY

JscEngine::JscEngine(std::shared_ptr<utils::MessageQueue> mq)
: messageQueue_(mq ? std::move(mq) : std::make_shared<utils::MessageQueue>()) {
Expand Down
6 changes: 4 additions & 2 deletions src/foundation.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct ImplType {

#ifdef _MSC_VER

// MSVC only support the standart _Pragma on recent version, use the extension key word here
// MSVC only support the standard _Pragma on recent version, use the extension key word here
#define SCRIPTX_BEGIN_INCLUDE_LIBRARY __pragma(warning(push, 0))
#define SCRIPTX_END_INCLUDE_LIBRARY __pragma(pop)

Expand All @@ -73,10 +73,12 @@ struct ImplType {
// GCC can't suppress all warnings by -Wall
// suppress anything encountered explicitly
// 1. -Wcast-function-type for QuickJs
// 2. -Waddress for JSC nullable function symbol

#define SCRIPTX_BEGIN_INCLUDE_LIBRARY \
_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wall\"") \
_Pragma("GCC diagnostic ignored \"-Wcast-function-type\"")
_Pragma("GCC diagnostic ignored \"-Wcast-function-type\"") \
_Pragma("GCC diagnostic ignored \"-Waddress\"")

#define SCRIPTX_END_INCLUDE_LIBRARY _Pragma("GCC diagnostic pop")

Expand Down
3 changes: 2 additions & 1 deletion src/utils/MessageQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <functional>
#include <limits>
#include <mutex>
#include <stdexcept>
#include <vector>
#include "../foundation.h"
#include "MemoryPool.hpp"
Expand Down Expand Up @@ -58,7 +59,7 @@ struct alignas(std::max_align_t) ArbitraryData {
inline ArbitraryData& ArbitraryData::operator=(const ArbitraryData& copy) {
// copy ArbitraryData byte-by-byte
// since is may be used as a chunk of memory to support placement new.
std::memcpy(this, &copy, sizeof(copy)); // NOLINT
std::memcpy(static_cast<void*>(this), &copy, sizeof(copy)); // NOLINT
return *this;
}

Expand Down
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.6)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down Expand Up @@ -143,7 +143,7 @@ if (${SCRIPTX_BACKEND} STREQUAL ${SCRIPTX_BACKEND_WEBASSEMBLY})
)
target_link_options(UnitTests PRIVATE
"-sEXPORTED_FUNCTIONS=['_main']"
"-sEXTRA_EXPORTED_RUNTIME_METHODS=['callMain']")
"-sEXPORTED_RUNTIME_METHODS=['callMain', 'HEAPU8', 'HEAP8', 'allocateUTF8']")
endif ()

add_test(
Expand Down
12 changes: 6 additions & 6 deletions test/src/NativeTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class TestClass : public ScriptClass {
static TestClass* create(const Arguments& args) { return new TestClass(args.thiz()); }
};

const ClassDefine<TestClass> TestClassDefAll =
static const ClassDefine<TestClass> TestClassDefAll =
defineClass<TestClass>("TestClass")
.nameSpace("script.engine.test")
.constructor()
Expand All @@ -86,14 +86,14 @@ const ClassDefine<TestClass> TestClassDefAll =
.instanceProperty("src", &TestClass::getSrc, &TestClass::setSrc)
.build();

const ClassDefine<TestClass> TestClassDefStatic =
static const ClassDefine<TestClass> TestClassDefStatic =
defineClass<TestClass>("TestClass")
.nameSpace("script.engine.test")
.function("add", &TestClass::add)
.property("version", &TestClass::getVersion, &TestClass::setVersion)
.build();

const ClassDefine<TestClass> TestClassDefInstance =
static const ClassDefine<TestClass> TestClassDefInstance =
defineClass<TestClass>("TestClass")
.nameSpace("script.engine.test")
.constructor(TestClass::create)
Expand Down Expand Up @@ -664,7 +664,7 @@ class InternalStorageTest : public ScriptClass {
Local<Value> getVal() { return getInternalStore().get(0); }
};

ClassDefine<InternalStorageTest> internalStorageTest =
static ClassDefine<InternalStorageTest> internalStorageTest =
defineClass<InternalStorageTest>("InternalStorageTest")
.constructor()
.instanceProperty("val", &InternalStorageTest::getVal, &InternalStorageTest::setVal)
Expand Down Expand Up @@ -860,7 +860,7 @@ TEST_F(NativeTest, MissMatchedType) {

EngineScope scope(engine);

auto def = defineClass<Instance>("Instance")
static auto def = defineClass<Instance>("Instance")
.constructor()
.function("sfun", &Instance::sfun)
.instanceFunction("fun", &Instance::fun)
Expand Down Expand Up @@ -1083,7 +1083,7 @@ TEST_F(NativeTest, NativeFounction) {
using ScriptClass::ScriptClass;
};

auto def = defineClass<Instance>("Instance")
static auto def = defineClass<Instance>("Instance")
.constructor()
.instanceFunction("f", [](Instance*, int) {})
.build();
Expand Down
1 change: 1 addition & 0 deletions test/src/ThreadPoolTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <array>
#include <atomic>
#include <chrono>
#include <cmath>
#include <iomanip>
#include "test.h"
Expand Down
2 changes: 1 addition & 1 deletion test/src/ValueTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ void testNumber(T value) {
EXPECT_EQ(num.toInt64(), static_cast<int64_t>(value));
#endif
EXPECT_FLOAT_EQ(num.toFloat(), static_cast<float>(value));
EXPECT_FLOAT_EQ(num.toDouble(), static_cast<double>(value));
EXPECT_DOUBLE_EQ(num.toDouble(), static_cast<double>(value));
}

TEST_F(ValueTest, Number) {
Expand Down
Loading