Skip to content

Commit

Permalink
Adds tests file b-examples.el and CI test script
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonwasrobot committed Jun 29, 2023
1 parent 349fdad commit 4e39164
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/b-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: b.el Tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
emacs_version:
- 24.4
- 29.0
- snapshot
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Emacs
uses: purcell/[email protected]
with:
version: ${{ matrix.emacs_version }}

- name: Test
run: |
bin/setup.sh
bin/tests.sh
# docs:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: purcell/[email protected]
# with:
# version: 28.1
# - name: Generate documentation
# run: |
# bin/setup.sh
# echo " Test Doc generation..."
# bin/docs.sh
# echo "════════════════════════════════════════════════════════════════════════════════"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@

# Undo-tree save-files
*.~undo-tree

# macOS
.DS_Store
2 changes: 2 additions & 0 deletions b.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

;;; Code:

;; Dependencies

(require 'dash) ; Too damn convenient.

;; Dec <-> Hex
Expand Down
40 changes: 40 additions & 0 deletions bin/docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh
etd="$(dirname "$(find ~/.emacs.d | grep "/etd.el$" | tail -1)")"
dash="$(dirname "$(find ~/.emacs.d | grep "/dash.el$" | tail -1)")"

cat <<INFO
════════════════════════════════════════════════════════════════════════════════
_ _
| | | |
| |__ ___| |
| '_ \ / _ \ |
| |_) | __/ |
|_.__(_)___|_|
_
| |
__| | ___ ___ ___
/ _` |/ _ \ / __/ __|
| (_| | (_) | (__\__ \\
\__,_|\___/ \___|___/
────────────────────────────────────────────────────────────────────────────────
Required packages present:
ETD: $etd
Dash: $dash
════════════════════════════════════════════════════════════════════════════════
$(emacs --version)
════════════════════════════════════════════════════════════════════════════════
INFO
emacs --batch \
-eval "(add-to-list 'load-path \".\")" \
-eval "(add-to-list 'load-path \"${etd}\")" \
-eval "(add-to-list 'load-path \"${dash}\")" \
-l ert \
-l etd \
-l ./b.el \
-l ./dev/b-examples.el \
--eval "(message \"Update README.md\")" \
--eval "(etd-create-docs-file-for \"dev/b-examples.el\" \"dev/doc-template\" \"README.md\")" \
--eval "(message \"Update index.md\")" \
--eval "(etd-create-docs-file-for \"dev/b-examples.el\" \"dev/index-template\" \"index.md\")"
21 changes: 21 additions & 0 deletions bin/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh -e

# For CI / Github Actions

EMACS="${EMACS:=emacs}"

NEEDED_PACKAGES="etd dash"

INIT_PACKAGE_EL="(progn \
(require 'package) \
(push '(\"melpa\" . \"https://melpa.org/packages/\") package-archives) \
(package-initialize) \
(package-refresh-contents) \
(dolist (pkg '(${NEEDED_PACKAGES})) \
(unless (package-installed-p pkg) \
(package-install pkg))))"

# Refresh package archives, because the test suite needs to see at least
# package-lint and cl-lib.
"$EMACS" -batch \
--eval "$INIT_PACKAGE_EL"
46 changes: 46 additions & 0 deletions bin/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh

etd="$(dirname "$(find ~/.emacs.d | grep "/etd.el$" | tail -1)")"
dash="$(dirname "$(find ~/.emacs.d | grep "/dash.el$" | tail -1)")"

EMACS="${EMACS:=emacs}"

cat <<INFO
════════════════════════════════════════════════════════════════════════════════
_ _
| | | |
| |__ ___| |
| '_ \ / _ \ |
| |_) | __/ |
|_.__(_)___|_|
_ _
| | | |
| |_ ___ ___| |_ ___
| __/ _ \/ __| __/ __|
| || __/\__ \ |_\__ \\
\__\___||___/\__|___/
────────────────────────────────────────────────────────────────────────────────
Required packages present:
ETD: $etd
Dash: $dash
════════════════════════════════════════════════════════════════════════════════
$("$EMACS" --version)
════════════════════════════════════════════════════════════════════════════════
INFO

"$EMACS" --batch \
-eval "(add-to-list 'load-path \"${dash}\")" \
-eval "(add-to-list 'load-path \"${etd}\")" \
-eval "(add-to-list 'load-path \".\")" \
-l ert \
-l dash \
-l etd \
-l ./b.el \
-l ./dev/b-examples.el \
--eval "(ert-run-tests-batch-and-exit)"
exitcode=$?

echo "
════════════════════════════════════════════════════════════════════════════════"
exit $exitcode
21 changes: 21 additions & 0 deletions dev/b-examples.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
;;; b-examples --- tests for b.el -*- lexical-binding: t; -*-

;; Dependencies

(require 'etd)
(require 'b)

(etd-group "Conversion functions"
(etd-examples b-dec-to-hex
(b-dec-to-hex 2) => "02"
(b-dec-to-hex 16) => "10"
(b-dec-to-hex 280) => "0118"))

;; (etd-group "Bit manipulation"
;; )

;; (etd-group "Byte parsing"
;; )


;;; b-examples.el ends here

0 comments on commit 4e39164

Please sign in to comment.