fix: cross-platform CI test fixes and parse bug fix

- Add .gitattributes to force LF in mock files (Windows autocrlf)
- Fix parse.go: detect line endings from content instead of runtime.GOOS
- Add fail-fast: false to CI matrix; trigger on all branch pushes
- Skip chmod-based tests on Windows (permissions work differently)
- Use filepath.Join for expected paths in Windows path tests
- Use platform-appropriate invalid paths in error tests
- Add Windows absolute path test case for ValidateSheetName
- Skip Unix-specific integration tests on Windows

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Christopher Allen Lane
2026-02-14 21:31:26 -05:00
parent b604027205
commit 8eafa5adfe
13 changed files with 83 additions and 31 deletions

View File

@@ -3,6 +3,7 @@ package sheet
import (
"os"
"path/filepath"
"runtime"
"testing"
)
@@ -130,6 +131,10 @@ func TestCopyIOError(t *testing.T) {
// TestCopyCleanupOnError verifies that partially written files are cleaned up on error
func TestCopyCleanupOnError(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("chmod does not restrict reads on Windows")
}
// Create a source file that we'll make unreadable after opening
src, err := os.CreateTemp("", "copy-test-cleanup-*")
if err != nil {

View File

@@ -2,7 +2,6 @@ package sheet
import (
"fmt"
"runtime"
"strings"
"gopkg.in/yaml.v3"
@@ -11,9 +10,9 @@ import (
// Parse parses cheatsheet frontmatter
func parse(markdown string) (frontmatter, string, error) {
// determine the appropriate line-break for the platform
// detect the line-break style used in the content
linebreak := "\n"
if runtime.GOOS == "windows" {
if strings.Contains(markdown, "\r\n") {
linebreak = "\r\n"
}

View File

@@ -1,17 +1,11 @@
package sheet
import (
"runtime"
"testing"
)
// TestParseWindowsLineEndings tests parsing with Windows line endings
func TestParseWindowsLineEndings(t *testing.T) {
// Only test Windows line endings on Windows
if runtime.GOOS != "windows" {
t.Skip("Skipping Windows line ending test on non-Windows platform")
}
// stub our cheatsheet content with Windows line endings
markdown := "---\r\nsyntax: go\r\ntags: [ test ]\r\n---\r\nTo foo the bar: baz"