Skip to content

Commit

Permalink
Start adding more windows testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
bakpakin committed Sep 24, 2024
1 parent 321093e commit d015a35
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 14 deletions.
54 changes: 49 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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`)"
3 changes: 3 additions & 0 deletions bundle/init.janet
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
5 changes: 5 additions & 0 deletions spork/cc.janet
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 5 additions & 7 deletions spork/misc.janet
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -128,7 +126,7 @@
(string/repeat " " (- width len))
item
""))
(buffer/push topbuf eol))
(buffer/push topbuf "\n"))
(buffer/push topbuf botbuf)
topbuf)

Expand Down
2 changes: 2 additions & 0 deletions src/cmath.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/suite-misc.janet
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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})
Expand Down

0 comments on commit d015a35

Please sign in to comment.