diff --git a/.github/workflows/cmake.yml b/.github/workflows/nix_ci.yml similarity index 60% rename from .github/workflows/cmake.yml rename to .github/workflows/nix_ci.yml index f96db45..5c11b27 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/nix_ci.yml @@ -1,4 +1,4 @@ -name: build & run tests +name: build & run tests (NIX) on: push: @@ -13,10 +13,10 @@ jobs: matrix: build-type: [Release] # Debug lua: ["lua 5.1", "lua 5.2", "lua 5.3", "luajit 2.0"] - os: ["macos-latest", "ubuntu-latest"] # "windows-latest" + os: ["macos-latest", "ubuntu-latest"] include: - - os: macos-latest - macos_build_target: 10.0 + - os: macos-latest + macos_build_target: 10.0 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 @@ -31,12 +31,16 @@ jobs: run: | pip install hererocks hererocks lua-pkg --${{ matrix.lua }} -rlatest - - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DLUA_INCLUDE_DIR="${{github.workspace}}/lua-pkg/include" - - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{matrix.build-type}} + source ${{github.workspace}}/lua-pkg/bin/activate + + - name: Configure CMake && build + run: | + cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DLUA_INCLUDE_DIR="${{github.workspace}}/lua-pkg/include" + cmake --build ${{github.workspace}}/build --config ${{matrix.build-type}} + - name: Test working-directory: ${{github.workspace}}/build + env: + STRESS: 1 run: | - source ${{github.workspace}}/lua-pkg/bin/activate - STRESS=1 lua ../tests/lua/run_tests + ${{github.workspace}}/lua-pkg/bin/lua ../tests/lua/run_tests diff --git a/.github/workflows/win_ci.yml b/.github/workflows/win_ci.yml new file mode 100644 index 0000000..23dd25c --- /dev/null +++ b/.github/workflows/win_ci.yml @@ -0,0 +1,48 @@ +name: build & run tests (Win) + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + strategy: + fail-fast: false + matrix: + build-type: [Release] # Debug + lua: ["lua 5.1", "lua 5.2", "lua 5.3", "luajit 2.0"] + os: ["windows-2016"] + platform: [ + {"forLua": "vs_32", "forCMake": "Win32"}, + {"forLua": "vs_64", "forCMake": "x64"}, + ] + exclude: + - lua: "luajit 2.0" + platform: {"forLua": "vs_32", "forCMake": "Win32"} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - uses: actions/setup-python@v2 + with: + python-version: '3.8' + - name: Setup env + run: | + pip install hererocks + hererocks lua-pkg --${{ matrix.lua }} -rlatest --target ${{matrix.platform.forLua}} + cmd ${{github.workspace}}\lua-pkg\bin\activate + + - name: Configure CMake & build + run: | + cmake -A ${{matrix.platform.forCMake}} -B ${{github.workspace}}\build -DLUA_INCLUDE_DIR="${{github.workspace}}/lua-pkg/include" -DLUA_LIBRARY="${{github.workspace}}/lua-pkg/lib/lua*.lib" + cmake --build ${{github.workspace}}/build --config ${{matrix.build-type}} + + - name: Test + working-directory: ${{github.workspace}}/build + env: + STRESS: 1 + run: | + ${{github.workspace}}/lua-pkg/bin/lua ../tests/lua/run_tests diff --git a/CMakeLists.txt b/CMakeLists.txt index f33e5c8..9453f94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,8 +41,8 @@ FILE(GLOB SOURCES src/cpp/*.cpp src/cpp/*.h) FILE(GLOB LUA_SOURCES src/lua/*.lua) add_library(effil SHARED ${SOURCES}) -target_link_libraries(effil ${LUA_LIBRARY}) -if (WIN32) +if (WIN32 OR WIN64) + target_link_libraries(effil ${LUA_LIBRARY}) set_target_properties(effil PROPERTIES PREFIX "" SUFFIX .dll) diff --git a/tests/lua/channel-stress.lua b/tests/lua/channel-stress.lua index 1dfffcc..2cf049c 100644 --- a/tests/lua/channel-stress.lua +++ b/tests/lua/channel-stress.lua @@ -47,29 +47,26 @@ test.channel_stress.with_multiple_threads = function () end end --- TODO: fix it for Windows -if not os.getenv("APPVEYOR") then - test.channel_stress.timed_read = function () - local chan = effil.channel() - local delayed_writer = function(channel, delay) - require("effil").sleep(delay) - channel:push("hello!") - end - effil.thread(delayed_writer)(chan, 70) - - local function check_time(real_time, use_time, metric, result) - local start_time = os.time() - test.equal(chan:pop(use_time, metric), result) - test.almost_equal(os.time(), start_time + real_time, 1) - end - check_time(2, 2, nil, nil) -- second by default - check_time(2, 2, 's', nil) - check_time(60, 1, 'm', nil) - - local start_time = os.time() - test.equal(chan:pop(10), "hello!") - test.is_true(os.time() < start_time + 10) +test.channel_stress.timed_read = function () + local chan = effil.channel() + local delayed_writer = function(channel, delay) + require("effil").sleep(delay) + channel:push("hello!") end + effil.thread(delayed_writer)(chan, 70) + + local function check_time(real_time, use_time, metric, result) + local start_time = os.time() + test.equal(chan:pop(use_time, metric), result) + test.almost_equal(os.time(), start_time + real_time, 2) + end + check_time(2, 2, nil, nil) -- second by default + check_time(2, 2, 's', nil) + check_time(60, 1, 'm', nil) + + local start_time = os.time() + test.equal(chan:pop(10), "hello!") + test.is_true(os.time() < start_time + 10) end -- regress for channel returns