Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kemal Akkoyun <[email protected]>
  • Loading branch information
kakkoyun committed Nov 27, 2023
1 parent 4ec3b98 commit 9f1019e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
23 changes: 21 additions & 2 deletions pkg/runtime/nodejs/nodejs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,32 @@ import (
"bytes"
"debug/elf"
"io"
"path"
"runtime"
"testing"

"github.com/stretchr/testify/require"
)

const testdata = "../../../testdata"

func arch() string {
ar := runtime.GOARCH
switch ar {
case "amd64":
return "x86"
default:
return ar
}
}

//nolint:unparam
func testBinaryPath(p string) string {
return path.Join(testdata, "vendored", arch(), p)
}

func Test_scanVersionBytes(t *testing.T) {
ef, err := elf.Open("testdata/node")
ef, err := elf.Open(testBinaryPath("node20.8"))
require.NoError(t, err)
t.Cleanup(func() { ef.Close() })

Expand Down Expand Up @@ -148,7 +167,7 @@ func Test_isNodeJSLib(t *testing.T) {
}

func Benchmark_scanVersionBytes(b *testing.B) {
ef, err := elf.Open("testdata/node")
ef, err := elf.Open(testBinaryPath("node20.8"))
require.NoError(b, err)

sec := ef.Section(".rodata")
Expand Down

0 comments on commit 9f1019e

Please sign in to comment.