Skip to content

Commit

Permalink
Switch to perevir for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tarleb committed Sep 2, 2024
1 parent 1e78f0f commit 4a027e6
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 25 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ jobs:
uses: actions/checkout@v2

- name: Install dependencies
run: apk add make
run: apk add luarocks5.4 make

- name: Install perevir
run: luarocks-5.4 install perevir

- name: Test
run: make test
run: |
eval $(luarocks-5.4 path)
make test
25 changes: 2 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,13 @@
# Name of the filter file, *with* `.lua` file extension.
FILTER_FILE := $(wildcard *.lua)
# Name of the filter, *without* `.lua` file extension
FILTER_NAME = $(patsubst %.lua,%,$(FILTER_FILE))

# Allow to use a different pandoc binary, e.g. when testing.
PANDOC ?= pandoc
# Allow to adjust the diff command if necessary
DIFF = diff

# Test that running the filter on the sample input document yields
# the expected output.
#
# The automatic variable `$<` refers to the first dependency
# (i.e., the filter file).
test: $(FILTER_FILE) test/input.md test/test.yaml
$(PANDOC) --defaults test/test.yaml | \
$(DIFF) test/expected.md -
test: test/perevirka.md
$(PANDOC) lua test/runtests.lua $<

# Ensure that the `test` target is run each time it's called.
.PHONY: test

# Re-generate the expected output. This file **must not** be a
# dependency of the `test` target, as that would cause it to be
# regenerated on each run, making the test pointless.
test/expected.md: $(FILTER_FILE) test/input.md test/test.yaml
$(PANDOC) --defaults test/test.yaml --output=$@

#
# Clean
#
.PHONY: clean
clean:
rm -f _site/output.md _site/index.html _site/style.css
38 changes: 38 additions & 0 deletions test/perevirka.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
perevir:
filters:
- cito.lua
metastrings-to-inlines: true
---

``` markdown {#input}
# Abstract

This is an example article. It was written under the influence of
coffee, which acts to counter fatigue [@cites_as_evidence:Li95].

# Further reading

Authors struggling to fill their document with content are referred to
@recommended_reading:Upper_writers_1974.
```

``` markdown {#expected}
---
cito_cites:
citesAsEvidence:
- Li95
citesAsRecommendedReading:
- Upper_writers_1974
---

# Abstract

This is an example article. It was written under the influence of
coffee, which acts to counter fatigue [@Li95].

# Further reading

Authors struggling to fill their document with content are referred to
@Upper_writers_1974.
```
9 changes: 9 additions & 0 deletions test/runtests.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env pandoc-lua
--- Run tests with perevir.
--
-- Copyright: © 2024 Albert Krewinkel <[email protected]>
-- License: MIT

local perevir = require 'perevir'
local opts = perevir.parse_args(arg)
perevir.do_checks(opts)

0 comments on commit 4a027e6

Please sign in to comment.