diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d632398..3ebba76 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,21 +4,23 @@ on: pull_request: name: Test env: - SASS_VERSION: 1.63.2 + SASS_VERSION: 1.77.5 jobs: test: strategy: matrix: - go-version: [~1.19, ~1.20] + go-version: [1.21.x, 1.22.x] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - name: Install Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install dart-sass Linux if: matrix.os == 'ubuntu-latest' run: | @@ -38,6 +40,8 @@ jobs: curl -LJO "https://github.com/sass/dart-sass/releases/download/${env:SASS_VERSION}/dart-sass-${env:SASS_VERSION}-windows-x64.zip"; Expand-Archive -Path "dart-sass-${env:SASS_VERSION}-windows-x64.zip" -DestinationPath .; echo "DART_SASS_BINARY=$env:GITHUB_WORKSPACE/dart-sass/sass.bat" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append + - name: Staticcheck + run: staticcheck ./... - name: Test run: go test -race . -coverprofile=coverage.txt -covermode=atomic - name: Upload coverage diff --git a/conn.go b/conn.go index 2b6042d..4b4b5a4 100644 --- a/conn.go +++ b/conn.go @@ -57,7 +57,6 @@ func (c conn) Start() error { // Close closes conn's WriteCloser, ReadClosers, and waits for the command to finish. func (c conn) Close() error { - writeErr := c.WriteCloser.Close() readErr := c.readerCloser.Close() var interruptErr error @@ -106,7 +105,7 @@ func (c conn) waitWithTimeout() error { } return err - case <-time.After(5 * time.Second): + case <-time.After(10 * time.Second): return errors.New("timed out waiting for dart-sass to finish") } } diff --git a/transpiler_test.go b/transpiler_test.go index 999cc12..d785f51 100644 --- a/transpiler_test.go +++ b/transpiler_test.go @@ -1,10 +1,8 @@ package godartsass_test import ( - "encoding/json" "errors" "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -63,7 +61,6 @@ func (t testImportResolver) Load(url string) (godartsass.Import, error) { panic("protocol error") } return godartsass.Import{Content: t.content, SourceSyntax: t.sourceSyntax}, nil - } func TestTranspilerVariants(t *testing.T) { @@ -179,19 +176,17 @@ body { } func TestIncludePaths(t *testing.T) { - dir1, _ := ioutil.TempDir(os.TempDir(), "libsass-test-include-paths-dir1") - defer os.RemoveAll(dir1) - dir2, _ := ioutil.TempDir(os.TempDir(), "libsass-test-include-paths-dir2") - defer os.RemoveAll(dir2) + dir1 := t.TempDir() + dir2 := t.TempDir() colors := filepath.Join(dir1, "_colors.scss") content := filepath.Join(dir2, "_content.scss") - ioutil.WriteFile(colors, []byte(` + os.WriteFile(colors, []byte(` $moo: #f442d1 !default; `), 0o644) - ioutil.WriteFile(content, []byte(` + os.WriteFile(content, []byte(` content { color: #ccc; } `), 0o644) @@ -330,7 +325,6 @@ div { color: $primary-color; }`, gor) wg.Wait() c.Assert(transpiler.IsShutDown(), qt.Equals, true) - } func BenchmarkTranspiler(b *testing.B) { @@ -414,7 +408,7 @@ func TestVersion(t *testing.T) { version, err := godartsass.Version(getSassEmbeddedFilename()) c.Assert(err, qt.IsNil) c.Assert(version, qt.Not(qt.Equals), "") - c.Assert(version.ProtocolVersion, qt.Equals, "2.0.0") + c.Assert(version.ProtocolVersion, qt.Equals, "2.7.1") } func newTestTranspiler(c *qt.C, opts godartsass.Options) (*godartsass.Transpiler, func()) { @@ -436,11 +430,3 @@ func getSassEmbeddedFilename() string { return "sass" } - -// used for debugging -func printJSON(s string) { - m := make(map[string]interface{}) - json.Unmarshal([]byte(s), &m) - b, _ := json.MarshalIndent(m, "", " ") - fmt.Printf("%s", b) -}