Commit 496abdd9

496abdd9f99bMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · ~2 modified

Description

test: switch fileio/fileopen tests to cwd-relative paths

The hardcoded `/tmp/spinel_test.txt` works on Linux/macOS but not under MSYS2: mingw64 ruby (the reference) raises ENOENT on `/tmp/...` while the spinel-generated native-Windows binary happens to resolve it via msvcrt's fopen — so the harness compared a CRuby error against a successful run and failed.

Cwd-relative paths sidestep the resolution-mismatch entirely. The harness runs each test from the project root sequentially, so the file lands there briefly and is removed by File.delete at the end of each test. Test stdout doesn't include the path, so the byte-for- byte comparison against CRuby is unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
496abdd9f99b
Parent
a09a6b8b339b

test/fileio.rbmodifiedView file

@@ -1,18 +1,22 @@
1-# Test basic File I/O
1+# Test basic File I/O.
2+# Uses cwd-relative paths so the harness (which runs each test from
3+# the project root) and the CRuby reference both write to the same
4+# place on every platform — `/tmp/...` doesn't resolve uniformly
5+# across MSYS2 mingw64 ruby and native-Windows-built spinel binaries.
26
37 # Write a file
4-File.write("/tmp/spinel_test.txt", "Hello from Spinel!\nLine 2\n")
8+File.write("spinel_test.txt", "Hello from Spinel!\nLine 2\n")
59
610 # Read the file
7-content = File.read("/tmp/spinel_test.txt")
11+content = File.read("spinel_test.txt")
812 puts content
913
1014 # File.exist?
11-puts File.exist?("/tmp/spinel_test.txt") # true
12-puts File.exist?("/tmp/nonexistent.txt") # false
15+puts File.exist?("spinel_test.txt") # true
16+puts File.exist?("spinel_nonexistent.txt") # false
1317
1418 # Clean up
15-File.delete("/tmp/spinel_test.txt")
16-puts File.exist?("/tmp/spinel_test.txt") # false
19+File.delete("spinel_test.txt")
20+puts File.exist?("spinel_test.txt") # false
1721
1822 puts "done"