From d015a3596d6a1dcd2cebdf14ada0e041f4262dbe Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Tue, 24 Sep 2024 07:48:34 -0500 Subject: [PATCH] Start adding more windows testing. --- .github/workflows/test.yml | 54 ++++++++++++++++++++++++++++++++++---- bundle/init.janet | 3 +++ spork/cc.janet | 5 ++++ spork/misc.janet | 12 ++++----- src/cmath.c | 2 ++ test/suite-misc.janet | 4 +-- 6 files changed, 66 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bde5ce0..51b630f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,10 +7,54 @@ on: branches: [ master ] jobs: - test: - - runs-on: ubuntu-latest + test-posix: + name: Build and test on POSIX systems + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, macos-13 ] + steps: + - name: Checkout Janet + uses: actions/checkout@v4 + with: + name: janet-lang/janet + path: janet + ref: refs/heads/master + - name: Build + Install Janet + run: cd janet && make clean && make && make install + - name: Checkout the repository + uses: actions/checkout@v4 + with: + path: spork + - name: Build Spork + run: cd spork && janet -l ./bundle -e "(build)" + - name: Run Tests + run: cd spork && janet -l ./bundle -e "(test)" + - name: Test Install + run: janet -e '(bundle/install "spork")' + test-windows: + name: Build and test on Windows + strategy: + matrix: + os: [ windows-latest, windows-2019 ] + runs-on: ${{ matrix.os }} steps: - - name: "Test project" - uses: pyrmont/action-janet-test@v2 + - name: Checkout the repository + uses: actions/checkout@v4 + with: + path: spork + - name: Setup MSVC + uses: ilammy/msvc-dev-cmd@v1 + - name: Download Janet Latest Release + shell: cmd + run: curl -fSLo janet.msi https://github.com/janet-lang/janet/releases/download/v1.36.0/janet-1.36.0-windows-x64-installer.msi + - name: Install Janet + shell: cmd + run: msiexec /i janet.msi /passive + - name: Build Spork + run: cd spork && janet -l ./bundle -e "(build)" + - name: Run Tests + run: cd spork && janet -l ./bundle -e "(test)" + - name: Test Install + run: janet -e "(bundle/install `spork`)" diff --git a/bundle/init.janet b/bundle/init.janet index 7fd70e2..6b8d9bd 100644 --- a/bundle/init.janet +++ b/bundle/init.janet @@ -39,6 +39,9 @@ :windows cc/msvc-compile-and-make-archive cc/compile-and-make-archive)) + (when (= :windows (os/which)) + (setdyn cc/*msvc-libs* (cc/msvc-janet-import-lib))) + (defn make1 [name & other-srcs] (def from (string "src/" name ".c")) diff --git a/spork/cc.janet b/spork/cc.janet index 205db59..ff25c94 100644 --- a/spork/cc.janet +++ b/spork/cc.janet @@ -91,6 +91,11 @@ (if (= "Library" (last parts)) (path/abspath (string sp "\\..\\C\\")))) +(defn msvc-janet-import-lib + "Get path to the installed Janet import lib. This import lib is needed when create dlls for natives." + [] + (string (msvc-cpath) "\\janet.lib")) + (defn- default-exec [&]) (defn- exec "Call the (dyn *visit*) function on commands" diff --git a/spork/misc.janet b/spork/misc.janet index c34f707..023d7b4 100644 --- a/spork/misc.janet +++ b/spork/misc.janet @@ -6,8 +6,6 @@ (import spork/rawterm) -(def- eol (if (= :windows (os/which)) "\r\n" "\n")) - (defn dedent ``` Remove indentation after concatenating the arguments. Works by removing @@ -110,10 +108,10 @@ (buffer/popn topbuf 3) (buffer/popn midbuf 3) (buffer/popn botbuf 3) # 3 bytes, 1 char - (buffer/push topbuf (string "╮" eol)) - (buffer/push midbuf (string "╡" eol)) - (buffer/push botbuf (string "╯" eol)) - (buffer/push hbuf eol) + (buffer/push topbuf (string "╮\n")) + (buffer/push midbuf (string "╡\n")) + (buffer/push botbuf (string "╯\n")) + (buffer/push hbuf "\n") # build large buffer (buffer/push topbuf hbuf midbuf) @@ -128,7 +126,7 @@ (string/repeat " " (- width len)) item "│")) - (buffer/push topbuf eol)) + (buffer/push topbuf "\n")) (buffer/push topbuf botbuf) topbuf) diff --git a/src/cmath.c b/src/cmath.c index 31c774c..1221e80 100644 --- a/src/cmath.c +++ b/src/cmath.c @@ -106,6 +106,8 @@ int64_t _mulmod_impl(int64_t a, int64_t b, int64_t m) { Janet wrap_nan() { #ifdef NAN return janet_wrap_number(NAN); +#elif defined(_MSC_VER) + return janet_wrap_nan(nan("nan")); #else return janet_wrap_number(0.0 / 0.0); #endif diff --git a/test/suite-misc.janet b/test/suite-misc.janet index c133e2b..38b9367 100644 --- a/test/suite-misc.janet +++ b/test/suite-misc.janet @@ -43,7 +43,7 @@ │ 4│5│5│5│5│ ╰────┴─┴─┴─┴─╯ ```) -(assert (= (-> output string/trim) (-> expected string/trim))) +(assert (= (-> output string/trim) (->> expected (string/replace-all "\r" "") string/trim))) (def output2 (misc/capout @@ -57,7 +57,7 @@ │ 小苹果│ 4│ ╰────────┴─────╯ ```) -(assert (= (-> output2 string/trim) (-> expected2 string/trim))) +(assert (= (-> output2 string/trim) (->> expected2 (string/replace-all "\r" "") string/trim))) (assert (deep= (misc/map-keys string {1 2 3 4}) @{"1" 2 "3" 4})