Skip to content

Commit

Permalink
Refine E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Feb 9, 2025
1 parent 41cb89e commit d26289a
Show file tree
Hide file tree
Showing 15 changed files with 318 additions and 49 deletions.
32 changes: 20 additions & 12 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,35 @@ jobs:
runs-on: ubuntu-24.04
timeout-minutes: 15
needs: [build]
# Don't use `nix develop` in this steps to avoid other devshell tools and make faster to run
steps:
- uses: actions/checkout@v4
- uses: dprint/check@2f1cf31537886c3bfb05591c031f7744e48ba8a1 # v2.2
- name: Install dprint
env:
DPRINT_CLI_VERSION: '${{ matrix.dprint-version }}'
run: |
curl -fsSL https://dprint.dev/install.sh | sh -s "$DPRINT_CLI_VERSION" > /dev/null 2>&1
echo "/home/runner/.dprint/bin" >> "$GITHUB_PATH"
- name: Install Task
uses: arduino/setup-task@v2
with:
dprint-version: '${{ matrix.dprint-version }}'
- name: Run with WASM plugin
version: '3.39.2' # selfup {"extract":"\\d\\.\\d+\\.\\d+","replacer":["task", "--version"], "nth": 3}
- name: Download pre-built plugin
env:
GH_TOKEN: ${{ github.token }}
run: |
gh run download '${{ github.run_id }}'
tree
- name: Make sure dependencies
run: |
dprint --version
dprint output-file-paths --config=dprint-dogfooding.json "--plugins=${PWD}/plugins/dprint_plugin_typstyle.wasm"
- run: dprint check --config=dprint-dogfooding.json "--plugins=${PWD}/plugins/dprint_plugin_typstyle.wasm"
id: dprint-check
continue-on-error: true
- run: false
if: steps.dprint-check.outcome == 'success'
- run: |
dprint fmt --config=dprint-dogfooding.json "--plugins=${PWD}/plugins/dprint_plugin_typstyle.wasm"
diff ./examples/raw.typ ./examples/expected.typ
task --version
diff --version
- name: Test
env:
PLUGIN_DIR: '${{ github.workspace }}/plugins/dprint_plugin_typstyle.wasm'
run:
task test
release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-24.04
Expand Down
44 changes: 33 additions & 11 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,47 @@

version: '3'

env:
PLUGIN_DIR: '{{.USER_WORKING_DIR}}/target/wasm32-unknown-unknown/release'

tasks:
default:
deps:
- task: check
- task: build
build:
- check
- build
build: # Prefer cargo cache rather than go-task cache feature
- cargo build --release --target=wasm32-unknown-unknown
check:
deps:
- task: test
- task: lint
- test
- lint
test:
deps:
- test-e2e-default
- test-e2e-all
- test-e2e-with_global_config
# cmds:
# - cargo test # There is no test. If adding here, required to update GitHub Actions workflow
test-e2e-*:
deps:
- build
vars:
TESTNAME: '{{index .MATCH 0}}'
cmds:
- cd 'tests/{{.TESTNAME}}' && dprint check --plugins="$PLUGIN_DIR/dprint_plugin_typstyle.wasm" expected.typ
- cd 'tests/{{.TESTNAME}}' && diff <(cat raw.typ | dprint fmt --stdin raw.typ --plugins="$PLUGIN_DIR/dprint_plugin_typstyle.wasm") expected.typ
bump-fixtures-*:
deps:
- build
vars:
TESTNAME: '{{index .MATCH 0}}'
cmds:
- cargo test
- cd 'tests/{{.TESTNAME}}' && cat raw.typ | dprint fmt --stdin raw.typ --plugins="$PLUGIN_DIR/dprint_plugin_typstyle.wasm" > expected.typ
bump-fixtures:
deps:
- bump-fixtures-default
- bump-fixtures-all
- bump-fixtures-with_global_config
fmt:
cmds:
- cargo fmt
Expand All @@ -29,11 +56,6 @@ tasks:
# nix fmt doesn't have check: https://github.com/NixOS/nix/issues/6918
- git ls-files '*.nix' | xargs nixfmt --check
- git ls-files | xargs selfup list -check
dogfooding: # Intentionally failing
deps:
- task: build
cmds:
- dprint check --config=dprint-dogfooding.json --plugins=./target/wasm32-unknown-unknown/release/dprint_plugin_typstyle.wasm
selfup:
cmds:
- git ls-files | xargs selfup run
Expand Down
6 changes: 0 additions & 6 deletions dprint-dogfooding.json

This file was deleted.

2 changes: 1 addition & 1 deletion dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"toml": {
},
"excludes": [".git", ".direnv", "target", "examples/expected*"],
"excludes": [".git", ".direnv", "target", "tests"],
"plugins": [
"https://plugins.dprint.dev/json-0.19.4.wasm",
"https://plugins.dprint.dev/markdown-0.17.8.wasm",
Expand Down
19 changes: 0 additions & 19 deletions examples/raw.typ

This file was deleted.

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
(with pkgs; [
bashInteractive
findutils # xargs
diffutils # for E2E test
nixfmt-rfc-style
nil
go-task
Expand Down
7 changes: 7 additions & 0 deletions tests/all/dprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"typst": {
"tab_spaces": 3,
"column": 20,
"blank_lines_upper_bound": 5,
},
}
40 changes: 40 additions & 0 deletions tests/all/expected.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#set text(
font: "New Computer Modern",


size: 10pt,
)
#set page(
paper: "a6",
margin: (
x: 1.8cm,
y: 1.5cm,
),
)
#set par(
justify: true,





leading: 0.52em,
)

This line has spaces.

This line is much much much much much much much much much much much much much much much much much much much much much much much much much much long.

#set rect(
width: 100%,
height: 100%,
inset: 4pt,
stroke: auto,
)

= Introduction
In this report, we will explore the
various factors that influence fluid
dynamics in glaciers and how they
contribute to the formation and
behaviour of these natural structures.
53 changes: 53 additions & 0 deletions tests/all/raw.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#set text(
font: "New Computer Modern"
,


size: 10pt
)
#set page(
paper: "a6",
margin: (x: 1.8cm, y: 1.5cm),
)
#set par(
justify: true,























leading: 0.52em,
)

This line has spaces.

This line is much much much much much much much much much much much much much much much much much much much much much much much much much much long.

#set rect(
width: 100%, height: 100%, inset: 4pt, stroke: auto
)

= Introduction
In this report, we will explore the
various factors that influence fluid
dynamics in glaciers and how they
contribute to the formation and
behaviour of these natural structures.
1 change: 1 addition & 0 deletions tests/default/dprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
15 changes: 15 additions & 0 deletions examples/expected.typ → tests/default/expected.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#set text(
font: "New Computer Modern",


size: 10pt,
)
#set page(
Expand All @@ -8,9 +10,22 @@
)
#set par(
justify: true,


leading: 0.52em,
)

This line has spaces.

This line is much much much much much much much much much much much much much much much much much much much much much much much much much much long.

#set rect(
width: 100%,
height: 100%,
inset: 4pt,
stroke: auto,
)

= Introduction
In this report, we will explore the
various factors that influence fluid
Expand Down
53 changes: 53 additions & 0 deletions tests/default/raw.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#set text(
font: "New Computer Modern"
,


size: 10pt
)
#set page(
paper: "a6",
margin: (x: 1.8cm, y: 1.5cm),
)
#set par(
justify: true,























leading: 0.52em,
)

This line has spaces.

This line is much much much much much much much much much much much much much much much much much much much much much much much much much much long.

#set rect(
width: 100%, height: 100%, inset: 4pt, stroke: auto
)

= Introduction
In this report, we will explore the
various factors that influence fluid
dynamics in glaciers and how they
contribute to the formation and
behaviour of these natural structures.
4 changes: 4 additions & 0 deletions tests/with_global_config/dprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"lineWidth": 20,
"indentWidth": 3
}
37 changes: 37 additions & 0 deletions tests/with_global_config/expected.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#set text(
font: "New Computer Modern",


size: 10pt,
)
#set page(
paper: "a6",
margin: (
x: 1.8cm,
y: 1.5cm,
),
)
#set par(
justify: true,


leading: 0.52em,
)

This line has spaces.

This line is much much much much much much much much much much much much much much much much much much much much much much much much much much long.

#set rect(
width: 100%,
height: 100%,
inset: 4pt,
stroke: auto,
)

= Introduction
In this report, we will explore the
various factors that influence fluid
dynamics in glaciers and how they
contribute to the formation and
behaviour of these natural structures.
Loading

0 comments on commit d26289a

Please sign in to comment.