Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc #25

Merged
merged 4 commits into from
Jul 11, 2024
Merged

Misc #25

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ 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: |
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions transpiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,11 @@ func (t *Transpiler) sendInboundMessage(compilationID uint32, message *embeddeds
return err
}

headerLen, err = t.conn.Write(out)
if headerLen != len(out) {
return errors.New("failed to write payload")
if _, err = t.conn.Write(out); err != nil {
return fmt.Errorf("failed to write payload: %w", err)
}

return err
return nil
}

type call struct {
Expand Down
24 changes: 5 additions & 19 deletions transpiler_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package godartsass_test

import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -330,7 +325,6 @@ div { color: $primary-color; }`, gor)
wg.Wait()

c.Assert(transpiler.IsShutDown(), qt.Equals, true)

}

func BenchmarkTranspiler(b *testing.B) {
Expand Down Expand Up @@ -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(strings.HasPrefix(version.ProtocolVersion, "2."), qt.IsTrue)
}

func newTestTranspiler(c *qt.C, opts godartsass.Options) (*godartsass.Transpiler, func()) {
Expand All @@ -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)
}
Loading