Skip to content

Commit

Permalink
Add crystal tool format tests (#55)
Browse files Browse the repository at this point in the history
Formatter tests are currently failing because not all shards have adopted the formatter changes in nightly. We should _hopefully_ see a green spec when testing against 1.14, but we can only do that once this PR is merged (automatic builds go against nightly, we can trigger a workflow_dispatch against other builds manually).
  • Loading branch information
straight-shoota authored Nov 26, 2024
1 parent fb0baf7 commit eec9ed9
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 1 deletion.
33 changes: 32 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,40 @@ jobs:
with:
bats-version: 1.9.0

- name: Configure git to not checkout CRLF
run: git config --global --add core.autocrlf false

- name: Test
run: |
bats --pretty --timing test --filter-tags !format
env:
WINDOWS_BASE_DIR: "/d/a"
TERM: dumb

test_format:
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4

- uses: crystal-lang/install-crystal@v1
with:
crystal: ${{ github.event.inputs.crystal || 'nightly' }}
shards: ${{ github.event.inputs.shards || 'nightly' }}

- name: Setup BATS
uses: mig4/setup-bats@v1
with:
bats-version: 1.9.0

- name: Configure git to not checkout CRLF
run: git config --global --add core.autocrlf false

- name: Test
run: |
bats --pretty --timing test
bats --pretty --timing test --filter-tags format
env:
WINDOWS_BASE_DIR: "/d/a"
TERM: dumb
18 changes: 18 additions & 0 deletions test/helper/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,21 @@ function shard_checkout() {
function crystal_spec() {
$CRYSTAL spec --junit_output ".junit/interpreter-std_spec.$BATS_TEST_NAME.xml"
}

function crystal_format() {
$CRYSTAL tool format --check || {
retval=$?

# Print formatter diff
$CRYSTAL tool format
git diff && git checkout -- .

return $retval
}
}

function check_crystal_format() {
shard_checkout "$1"

crystal_format
}
111 changes: 111 additions & 0 deletions test/libraries.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ function setup() {
crystal_spec
}

# bats test_tags=format
@test "format Sija/backtracer.cr" {
check_crystal_format https://github.com/Sija/backtracer.cr
}

# bats test_tags=openssl
@test "crystal-loot/exception_page" {
skip "Specs are failing (https://github.com/crystal-loot/exception_page/issues/39)"
Expand All @@ -25,12 +30,22 @@ function setup() {
crystal_spec
}

# bats test_tags=format
@test "format crystal-loot/exception_page" {
check_crystal_format https://github.com/crystal-loot/exception_page
}

@test "luislavena/radix" {
shard_checkout https://github.com/luislavena/radix

crystal_spec
}

# bats test_tags=format
@test "format luislavena/radix" {
check_crystal_format https://github.com/luislavena/radix
}

@test "ysbaddaden/pool" {
shard_checkout https://github.com/ysbaddaden/pool

Expand All @@ -43,18 +58,33 @@ function setup() {
crystal_spec
}

# bats test_tags=format
@test "format luckyframework/habitat" {
check_crystal_format https://github.com/luckyframework/habitat
}

@test "luckyframework/wordsmith" {
shard_checkout https://github.com/luckyframework/wordsmith

crystal_spec
}

# bats test_tags=format
@test "format luckyframework/wordsmith" {
check_crystal_format https://github.com/luckyframework/wordsmith
}

@test "crystal-community/future.cr" {
shard_checkout https://github.com/crystal-community/future.cr

crystal_spec
}

# bats test_tags=format
@test "format crystal-community/future.cr" {
check_crystal_format https://github.com/crystal-community/future.cr
}

@test "schovi/baked_file_system" {
skiponwindows "Does not build"
shard_checkout https://github.com/schovi/baked_file_system
Expand All @@ -81,19 +111,34 @@ function setup() {
crystal_spec
}

# bats test_tags=format
@test "format luckyframework/lucky_task" {
check_crystal_format https://github.com/luckyframework/lucky_task
}

@test "spider-gazelle/bindata" {
shard_checkout https://github.com/spider-gazelle/bindata

crystal_spec
}

# bats test_tags=format
@test "format spider-gazelle/bindata" {
check_crystal_format https://github.com/spider-gazelle/bindata
}

# bats test_tags=openssl
@test "kemalcr/kemal-session" {
shard_checkout https://github.com/kemalcr/kemal-session

crystal_spec
}

# bats test_tags=format
@test "format kemalcr/kemal-session" {
check_crystal_format https://github.com/kemalcr/kemal-session
}

# bats test_tags=openssl
@test "kemalcr/kemal" {
if [[ "$(crystal env CRYSTAL_VERSION)" =~ ^0\.|^1\.[0-8]\. ]]; then
Expand All @@ -106,6 +151,11 @@ function setup() {
crystal_spec
}

# bats test_tags=format
@test "format kemalcr/kemal" {
check_crystal_format https://github.com/kemalcr/kemal
}

@test "luckyframework/teeplate" {
skip "Wants to sign git commit"
skiponwindows "Does not build"
Expand All @@ -114,19 +164,34 @@ function setup() {
crystal_spec
}

# bats test_tags=format
@test "format luckyframework/teeplate" {
check_crystal_format https://github.com/luckyframework/teeplate
}

@test "icyleaf/markd" {
shard_checkout https://github.com/icyleaf/markd

crystal_spec
}

# bats test_tags=format
@test "format icyleaf/markd" {
check_crystal_format https://github.com/icyleaf/markd
}

@test "crystal-lang/json_mapping.cr" {
skiponwindows "Does not build"
shard_checkout https://github.com/crystal-lang/json_mapping.cr

crystal_spec
}

# bats test_tags=format
@test "format crystal-lang/json_mapping.cr" {
check_crystal_format https://github.com/crystal-lang/json_mapping.cr
}

@test "stumpycr/stumpy_png" {
skip "Incompatible with modern Crystal"
skiponwindows "Specs are failing"
Expand All @@ -135,20 +200,35 @@ function setup() {
crystal_spec
}

# bats test_tags=format
@test "format stumpycr/stumpy_png" {
check_crystal_format https://github.com/stumpycr/stumpy_png
}

@test "luckyframework/shell-table.cr" {
skip "Specs are failing"
shard_checkout https://github.com/luckyframework/shell-table.cr

crystal_spec
}

# bats test_tags=format
@test "format luckyframework/shell-table.cr" {
check_crystal_format https://github.com/luckyframework/shell-table.cr
}

@test "phoffer/inflector.cr" {
skip "Specs are failing"
shard_checkout https://github.com/phoffer/inflector.cr

crystal_spec
}

# bats test_tags=format
@test "format phoffer/inflector.cr" {
check_crystal_format https://github.com/phoffer/inflector.cr
}

# bats test_tags=cmake
@test "kostya/lexbor" {
skiponwindows "Specs are failing"
Expand All @@ -165,6 +245,11 @@ function setup() {
crystal_spec
}

# bats test_tags=format
@test "format icyleaf/halite" {
check_crystal_format https://github.com/icyleaf/halite
}

@test "jwaldrip/admiral.cr" {
shard_checkout https://github.com/jwaldrip/admiral.cr

Expand All @@ -188,19 +273,34 @@ function setup() {
crystal_spec
}

# bats test_tags=format
@test "format vladfaust/time_format.cr" {
check_crystal_format https://github.com/vladfaust/time_format.cr
}

@test "mamantoha/http_proxy" {
skiponwindows "Specs are failing"
shard_checkout https://github.com/mamantoha/http_proxy

crystal_spec
}

# bats test_tags=format
@test "format mamantoha/http_proxy" {
check_crystal_format https://github.com/mamantoha/http_proxy
}

@test "crystal-community/msgpack-crystal" {
shard_checkout https://github.com/crystal-community/msgpack-crystal

crystal_spec
}

# bats test_tags=format
@test "format crystal-community/msgpack-crystal" {
check_crystal_format https://github.com/crystal-community/msgpack-crystal
}

@test "spider-gazelle/openssl_ext" {
skiponwindows "Specs are failing"
shard_checkout https://github.com/spider-gazelle/openssl_ext
Expand All @@ -221,6 +321,11 @@ function setup() {
crystal_spec
}

# bats test_tags=format
@test "format maiha/pretty.cr" {
check_crystal_format https://github.com/maiha/pretty.cr
}

@test "straight-shoota/crinja" {
skiponwindows "Specs are failing"

Expand All @@ -231,3 +336,9 @@ function setup() {
cd examples
bats integration_test.bats
}

# bats test_tags=format
@test "format straight-shoota/crinja" {
check_crystal_format https://github.com/straight-shoota/crinja
}

20 changes: 20 additions & 0 deletions test/testing.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,43 @@ function setup() {
crystal_spec
}

# bats test_tags=format
@test "format ysbaddaden/minitest.cr" {
check_crystal_format https://github.com/ysbaddaden/minitest.cr
}

@test "arctic-fox/spectator" {
skip "Does not build"
shard_checkout https://gitlab.com/arctic-fox/spectator

crystal_spec
}

# bats test_tags=format
@test "format arctic-fox/spectator" {
check_crystal_format https://github.com/arctic-fox/spectator
}

@test "crystal-community/timecop.cr" {
skiponwindows "Timeout"
shard_checkout https://github.com/crystal-community/timecop.cr

crystal_spec
}

# bats test_tags=format
@test "format crystal-community/timecop.cr" {
check_crystal_format https://github.com/crystal-community/timecop.cr
}

@test "manastech/webmock.cr" {
skiponwindows "Specs are failing"
shard_checkout https://github.com/manastech/webmock.cr

crystal_spec
}

# bats test_tags=format
@test "format manastech/webmock.cr" {
check_crystal_format https://github.com/manastech/webmock.cr
}
5 changes: 5 additions & 0 deletions test/tools.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ function setup() {

crystal_spec
}

# bats test_tags=format
@test "format crystal-ameba/ameba" {
check_crystal_format https://github.com/crystal-ameba/ameba
}

0 comments on commit eec9ed9

Please sign in to comment.