Skip to content

Commit

Permalink
Let diff with golden test file ignore trailling cr
Browse files Browse the repository at this point in the history
For compatibility with windows.

And let GitHub action set GODOT_EXE env var on windows.
  • Loading branch information
bamboo committed Dec 1, 2024
1 parent 50c7e9b commit 3e8be0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ jobs:
with:
version: 4.3.0
use-dotnet: false
- name: Set GODOT_EXE on windows
if: ${{ matrix.platform == 'windows' }}
run: echo "GODOT_EXE=C:\Users\runneradmin\godot\Godot_v4.3-stable_win64.exe" >> $env:GITHUB_ENV
- name: Test
if: ${{ matrix.float-precision == 'single' && matrix.target-type == 'template_debug' && (matrix.platform == 'linux' || matrix.platform == 'macos' || (matrix.platform == 'windows' && matrix.arch == 'x86_64')) }}
run: make test -j
Expand Down
10 changes: 7 additions & 3 deletions test/test-main.scm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
(error 'assertion-error "ERROR~%# (assert-equals ~a ~a)~%## ~a~%`~a`~%## ~a~%`~a`" lq rq lq l' rq r')))))

(define (godot scene)
(let* ((program (or (getenv "GODOT") "godot"))
(let* ((program (or (getenv "GODOT_EXE") (getenv "GODOT") "godot"))
(cmd (format #f "\"~a\" --path demo ~a --headless --quit" program scene)))
(format #t "~a~%" cmd)
(system cmd #t)))
Expand All @@ -16,12 +16,16 @@
(call-with-input-file path
(lambda (p) (read-string 65535 p))))

(define (diff file1 file2)
(system (format #f "diff --strip-trailing-cr --color=auto -u ~a ~a" file1 file2)))

(define* (golden-scene-test scene golden-file)
(let ((output-file "bin/s7_scheme_tests.txt"))
(call-with-output-file output-file
(lambda (p) (write-string (godot scene) p)))
(unless (= 0 (system (format #f "diff --color=auto -u ~a ~a" golden-file output-file)))
(error 'assertion-error "ERROR: output of scene `~a` doesn't match golden file `~a`." scene golden-file))))
(unless (= 0 (diff golden-file output-file))
(error 'assertion-error
"ERROR: output of scene `~a` doesn't match golden file `~a`." scene golden-file))))

(define (golden-scene-tests)
(golden-scene-test
Expand Down

0 comments on commit 3e8be0b

Please sign in to comment.