Skip to content
Open
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
35 changes: 35 additions & 0 deletions internal/ixgo/pkg/github.com/goplus/llar/cmp/export.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// export by github.com/goplus/ixgo/cmd/qexp

package cmp

import (
q "github.com/goplus/llar/cmp"

"go/constant"
"reflect"

"github.com/goplus/ixgo"
)

func init() {
ixgo.RegisterPackage(&ixgo.Package{
Name: "cmp",
Path: "github.com/goplus/llar/cmp",
Deps: map[string]string{
"github.com/goplus/llar/mod/module": "module",
},
Interfaces: map[string]reflect.Type{},
NamedTypes: map[string]reflect.Type{
"CmpApp": reflect.TypeOf((*q.CmpApp)(nil)).Elem(),
},
AliasTypes: map[string]reflect.Type{},
Vars: map[string]reflect.Value{},
Funcs: map[string]reflect.Value{
"Gopt_CmpApp_Main": reflect.ValueOf(q.Gopt_CmpApp_Main),
},
TypedConsts: map[string]ixgo.TypedConst{},
UntypedConsts: map[string]ixgo.UntypedConst{
"GopPackage": {"untyped bool", constant.MakeBool(bool(q.GopPackage))},
},
})
}
2 changes: 2 additions & 0 deletions internal/ixgo/pkgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package ixgo

//go:generate qexp -outdir pkg github.com/goplus/llar/formula
//go:generate qexp -outdir pkg github.com/goplus/llar/cmp
//go:generate qexp -outdir pkg github.com/goplus/llar/mod/versions
//go:generate qexp -outdir pkg golang.org/x/mod/semver
//go:generate qexp -outdir pkg github.com/goplus/llar/x/gnu
Expand Down Expand Up @@ -178,6 +179,7 @@ import (
// _ "github.com/goplus/ixgo/pkg/testing/iotest"
// _ "github.com/goplus/ixgo/pkg/testing/quick"
// _ "github.com/goplus/ixgo/pkg/testing/slogtest"
_ "github.com/goplus/llar/internal/ixgo/pkg/github.com/goplus/llar/cmp"
_ "github.com/goplus/llar/internal/ixgo/pkg/github.com/goplus/llar/formula"
_ "github.com/goplus/llar/internal/ixgo/pkg/github.com/goplus/llar/mod/module"
_ "github.com/goplus/llar/internal/ixgo/pkg/github.com/goplus/llar/mod/versions"
Expand Down
19 changes: 19 additions & 0 deletions internal/modules/comparator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package modules
import (
"io/fs"
"os"
"path/filepath"
"reflect"
"testing"

Expand Down Expand Up @@ -149,6 +150,24 @@ func TestLoadComparator_Fake(t *testing.T) {
}
}

func TestLoadComparator_OutsideModule(t *testing.T) {
formulaDir, err := filepath.Abs("testdata/DaveGamble/cJSON")
Comment thread
MeteorsLiu marked this conversation as resolved.
if err != nil {
t.Fatal(err)
}

// Formula repositories do not contain go.mod. For example, llarhub stores
// CJSON_cmp.gox beside versions.json, so loading it must not invoke go list.
Comment thread
MeteorsLiu marked this conversation as resolved.
t.Chdir(t.TempDir())
comp, err := loadComparatorFS(os.DirFS(formulaDir).(fs.ReadFileFS), "CJSON_cmp.gox")
if err != nil {
t.Fatalf("loadComparatorFS outside a module: %v", err)
}
if got := comp(module.Version{Version: "v1.0.0"}, module.Version{Version: "v2.0.0"}); got >= 0 {
Comment thread
MeteorsLiu marked this conversation as resolved.
t.Fatalf("comparison = %d, want a negative value", got)
}
}

func TestLoadComparator_InvalidFileExtension(t *testing.T) {
// Create a temp file with wrong extension
tempDir := t.TempDir()
Expand Down
Loading