-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from saffroy/master
Add tests for multiline statements, run tests in github workflow
- Loading branch information
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Run tests across emacs versions | ||
on: [push, pull_request] | ||
jobs: | ||
test-emacs-versions: | ||
strategy: | ||
matrix: | ||
emacs-version: [26, 27, 28, 29] | ||
runs-on: ubuntu-latest | ||
container: silex/emacs:${{matrix.emacs-version}} | ||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v4 | ||
- name: Install test dependencies | ||
run: ./install-deps.sh | ||
- name: Run tests | ||
run: ./runtests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
set -xeu | ||
|
||
apt-get update | ||
apt-get install -y nodejs | ||
apt-get clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
set -xeu | ||
|
||
cd "$(dirname $0)" | ||
emacs -Q --batch \ | ||
-l ert \ | ||
-l js-comint.el \ | ||
-l test-js-comint.el \ | ||
-f ert-run-tests-batch-and-exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
(defun js-comint-test-buffer-matches (regex) | ||
"Search the js-comint buffer for the given regular expression. | ||
Return 't if a match is found, nil otherwise." | ||
(with-current-buffer (js-comint-get-buffer) | ||
(save-excursion | ||
(goto-char (point-min)) | ||
(if (re-search-forward regex nil t) t nil)))) | ||
|
||
(defun js-comint-test-output-matches (input regex) | ||
"Verify that sending INPUT yields output that matches REGEX." | ||
|
||
;; Start an instance to run tests on. | ||
(js-comint-reset-repl) | ||
|
||
(sit-for 1) | ||
|
||
(js-comint-send-string input) | ||
|
||
(sit-for 1) | ||
|
||
(js-comint-test-buffer-matches regex)) | ||
|
||
(ert-deftest js-comint-test-multiline-dotchain-line-start () | ||
"Test multiline statement with dots at beginning of lines." | ||
(should (js-comint-test-output-matches "[1, 2, 3] | ||
.map((it) => it + 1) | ||
.filter((it) => it > 0) | ||
.reduce((prev, curr) => prev + curr, 0);" "^9$"))) | ||
|
||
(ert-deftest js-comint-test-multiline-dotchain-line-start-dos () | ||
"Test multiline statement with dots at beginning of lines, with | ||
DOS line separators." | ||
(should (js-comint-test-output-matches "[1, 2, 3]\r | ||
.map((it) => it + 1)\r | ||
.filter((it) => it > 0)\r | ||
.reduce((prev, curr) => prev + curr, 0);\r | ||
" "^9$"))) | ||
|
||
(ert-deftest js-comint-test-multiline-dotchain-line-end () | ||
"Test multiline statement with dots at end of lines." | ||
(should (js-comint-test-output-matches "[1, 2, 3]. | ||
map((it) => it + 1). | ||
filter((it) => it > 0). | ||
reduce((prev, curr) => prev + curr, 0);" "^9$"))) |