From 3e8be0beb095bc1410a6ae16c4aa52d18fd0721c Mon Sep 17 00:00:00 2001 From: "Rodrigo B. de Oliveira" Date: Sat, 30 Nov 2024 17:46:13 -0300 Subject: [PATCH] Let diff with golden test file ignore trailling cr For compatibility with windows. And let GitHub action set GODOT_EXE env var on windows. --- .github/workflows/builds.yml | 3 +++ test/test-main.scm | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 8b2ae2a..f8616d6 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -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 diff --git a/test/test-main.scm b/test/test-main.scm index 66b9f32..ba29c13 100644 --- a/test/test-main.scm +++ b/test/test-main.scm @@ -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))) @@ -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