mirror of
https://github.com/Jguer/yay.git
synced 2025-12-27 07:35:48 -05:00
@@ -10,6 +10,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -508,10 +509,8 @@ func TestIntegrationLocalInstallGenerateSRCINFO(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
captureOverride := func(cmd *exec.Cmd) (stdout string, stderr string, err error) {
|
captureOverride := func(cmd *exec.Cmd) (stdout string, stderr string, err error) {
|
||||||
for _, arg := range cmd.Args {
|
if slices.Contains(cmd.Args, "--printsrcinfo") {
|
||||||
if arg == "--printsrcinfo" {
|
return string(srcinfo), "", nil
|
||||||
return string(srcinfo), "", nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return strings.Join(tars, "\n"), "", nil
|
return strings.Join(tars, "\n"), "", nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -529,14 +529,14 @@ func (ae *AlpmExecutor) AlpmArchitectures() ([]string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func alpmSetLogCallback(alpmHandle *alpm.Handle, cb func(alpm.LogLevel, string)) {
|
func alpmSetLogCallback(alpmHandle *alpm.Handle, cb func(alpm.LogLevel, string)) {
|
||||||
alpmHandle.SetLogCallback(func(ctx interface{}, lvl alpm.LogLevel, msg string) {
|
alpmHandle.SetLogCallback(func(ctx any, lvl alpm.LogLevel, msg string) {
|
||||||
cbo := ctx.(func(alpm.LogLevel, string))
|
cbo := ctx.(func(alpm.LogLevel, string))
|
||||||
cbo(lvl, msg)
|
cbo(lvl, msg)
|
||||||
}, cb)
|
}, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
func alpmSetQuestionCallback(alpmHandle *alpm.Handle, cb func(alpm.QuestionAny)) {
|
func alpmSetQuestionCallback(alpmHandle *alpm.Handle, cb func(alpm.QuestionAny)) {
|
||||||
alpmHandle.SetQuestionCallback(func(ctx interface{}, q alpm.QuestionAny) {
|
alpmHandle.SetQuestionCallback(func(ctx any, q alpm.QuestionAny) {
|
||||||
cbo := ctx.(func(alpm.QuestionAny))
|
cbo := ctx.(func(alpm.QuestionAny))
|
||||||
cbo(q)
|
cbo(q)
|
||||||
}, cb)
|
}, cb)
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
|
import "slices"
|
||||||
|
|
||||||
func ArchIsSupported(alpmArch []string, arch string) bool {
|
func ArchIsSupported(alpmArch []string, arch string) bool {
|
||||||
if arch == "any" {
|
if arch == "any" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, a := range alpmArch {
|
return slices.Contains(alpmArch, arch)
|
||||||
if a == arch {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -244,8 +244,6 @@ func (g *Grapher) GraphFromSrcInfos(ctx context.Context, graph *topo.Graph[strin
|
|||||||
|
|
||||||
aurPkgsAdded := []*aurc.Pkg{}
|
aurPkgsAdded := []*aurc.Pkg{}
|
||||||
for pkgBuildDir, pkgbuild := range srcInfos {
|
for pkgBuildDir, pkgbuild := range srcInfos {
|
||||||
pkgBuildDir := pkgBuildDir
|
|
||||||
|
|
||||||
aurPkgs, err := makeAURPKGFromSrcinfo(g.dbExecutor, pkgbuild)
|
aurPkgs, err := makeAURPKGFromSrcinfo(g.dbExecutor, pkgbuild)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -260,8 +258,6 @@ func (g *Grapher) GraphFromSrcInfos(ctx context.Context, graph *topo.Graph[strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, pkg := range aurPkgs {
|
for _, pkg := range aurPkgs {
|
||||||
pkg := pkg
|
|
||||||
|
|
||||||
reason := Explicit
|
reason := Explicit
|
||||||
if pkg := g.dbExecutor.LocalPackage(pkg.Name); pkg != nil {
|
if pkg := g.dbExecutor.LocalPackage(pkg.Name); pkg != nil {
|
||||||
reason = Reason(pkg.Reason())
|
reason = Reason(pkg.Reason())
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package topo
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Jguer/go-alpm/v2"
|
"github.com/Jguer/go-alpm/v2"
|
||||||
@@ -344,9 +345,7 @@ func (g *Graph[T, V]) buildTransitive(root T, nextFn func(T) NodeSet[T]) NodeSet
|
|||||||
|
|
||||||
func (s NodeSet[T]) copy() NodeSet[T] {
|
func (s NodeSet[T]) copy() NodeSet[T] {
|
||||||
out := make(NodeSet[T], len(s))
|
out := make(NodeSet[T], len(s))
|
||||||
for k, v := range s {
|
maps.Copy(out, s)
|
||||||
out[k] = v
|
|
||||||
}
|
|
||||||
|
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ func Test_getPackageURL(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
got := getPackagePKGBUILDURL(tt.args.pkgName)
|
got := getPackagePKGBUILDURL(tt.args.pkgName)
|
||||||
@@ -174,7 +173,6 @@ func TestGetABSPkgbuild(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
httpClient := &testClient{
|
httpClient := &testClient{
|
||||||
@@ -257,7 +255,6 @@ func Test_getPackageRepoURL(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
got := getPackageRepoURL(tt.args.pkgName)
|
got := getPackageRepoURL(tt.args.pkgName)
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ func TestGetAURPkgbuild(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
httpClient := &testClient{
|
httpClient := &testClient{
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ func TestIntRange_Get(t *testing.T) {
|
|||||||
{name: "normal end range false", fields: fields{1, 2}, args: args{3}, want: false},
|
{name: "normal end range false", fields: fields{1, 2}, args: args{3}, want: false},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
r := IntRange{
|
r := IntRange{
|
||||||
@@ -183,7 +182,6 @@ func TestIntRanges_Get(t *testing.T) {
|
|||||||
{name: "normal end range false", rs: IntRanges{{1, 2}}, args: args{3}, want: false},
|
{name: "normal end range false", rs: IntRanges{{1, 2}}, args: args{3}, want: false},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
if got := tt.rs.Get(tt.args.n); got != tt.want {
|
if got := tt.rs.Get(tt.args.n); got != tt.want {
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ func editPkgbuilds(log *text.Logger, pkgbuildDirs map[string]string, bases []str
|
|||||||
if len(pkgbuilds) > 0 {
|
if len(pkgbuilds) > 0 {
|
||||||
editor, editorArgs := editor(log, editorConfig, editorFlags, noConfirm)
|
editor, editorArgs := editor(log, editorConfig, editorFlags, noConfirm)
|
||||||
editorArgs = append(editorArgs, pkgbuilds...)
|
editorArgs = append(editorArgs, pkgbuilds...)
|
||||||
editcmd := exec.Command(editor, editorArgs...)
|
editcmd := exec.CommandContext(context.Background(), editor, editorArgs...)
|
||||||
editcmd.Stdin, editcmd.Stdout, editcmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
editcmd.Stdin, editcmd.Stdout, editcmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
||||||
|
|
||||||
if err := editcmd.Run(); err != nil {
|
if err := editcmd.Run(); err != nil {
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ func TestPrintNewsFeed(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Setenv("TZ", "UTC")
|
t.Setenv("TZ", "UTC")
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
gock.New("https://archlinux.org").
|
gock.New("https://archlinux.org").
|
||||||
Get("/feeds/news").
|
Get("/feeds/news").
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ type SourceQueryBuilder struct {
|
|||||||
sortBy string
|
sortBy string
|
||||||
searchBy string
|
searchBy string
|
||||||
targetMode parser.TargetMode
|
targetMode parser.TargetMode
|
||||||
queryMap map[string]map[string]interface{}
|
queryMap map[string]map[string]any
|
||||||
bottomUp bool
|
bottomUp bool
|
||||||
singleLineResults bool
|
singleLineResults bool
|
||||||
separateSources bool
|
separateSources bool
|
||||||
@@ -71,7 +71,7 @@ func NewSourceQueryBuilder(
|
|||||||
searchBy: searchBy,
|
searchBy: searchBy,
|
||||||
singleLineResults: singleLineResults,
|
singleLineResults: singleLineResults,
|
||||||
separateSources: separateSources,
|
separateSources: separateSources,
|
||||||
queryMap: map[string]map[string]interface{}{},
|
queryMap: map[string]map[string]any{},
|
||||||
results: make([]abstractResult, 0, 100),
|
results: make([]abstractResult, 0, 100),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ func (s *SourceQueryBuilder) Execute(ctx context.Context, dbExecutor db.Executor
|
|||||||
|
|
||||||
for i := range aurResults {
|
for i := range aurResults {
|
||||||
if s.queryMap[dbName] == nil {
|
if s.queryMap[dbName] == nil {
|
||||||
s.queryMap[dbName] = map[string]interface{}{}
|
s.queryMap[dbName] = map[string]any{}
|
||||||
}
|
}
|
||||||
|
|
||||||
by := getSearchBy(s.searchBy)
|
by := getSearchBy(s.searchBy)
|
||||||
@@ -182,7 +182,7 @@ func (s *SourceQueryBuilder) Execute(ctx context.Context, dbExecutor db.Executor
|
|||||||
for i := range repoResults {
|
for i := range repoResults {
|
||||||
dbName := repoResults[i].DB().Name()
|
dbName := repoResults[i].DB().Name()
|
||||||
if s.queryMap[dbName] == nil {
|
if s.queryMap[dbName] == nil {
|
||||||
s.queryMap[dbName] = map[string]interface{}{}
|
s.queryMap[dbName] = map[string]any{}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.queryMap[dbName][repoResults[i].Name()] = repoResults[i]
|
s.queryMap[dbName][repoResults[i].Name()] = repoResults[i]
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ func (c *CmdBuilder) sudoLoopBackground() {
|
|||||||
|
|
||||||
func (c *CmdBuilder) updateSudo() {
|
func (c *CmdBuilder) updateSudo() {
|
||||||
for {
|
for {
|
||||||
err := c.Show(exec.Command(c.SudoBin, "-v"))
|
err := c.Show(exec.CommandContext(context.Background(), c.SudoBin, "-v"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Log.Errorln(err)
|
c.Log.Errorln(err)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Call struct {
|
type Call struct {
|
||||||
Res []interface{}
|
Res []any
|
||||||
Args []interface{}
|
Args []any
|
||||||
Dir string
|
Dir string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,8 +51,8 @@ func (m *MockBuilder) BuildMakepkgCmd(ctx context.Context, dir string, extraArgs
|
|||||||
|
|
||||||
m.BuildMakepkgCmdCallsMu.Lock()
|
m.BuildMakepkgCmdCallsMu.Lock()
|
||||||
m.BuildMakepkgCmdCalls = append(m.BuildMakepkgCmdCalls, Call{
|
m.BuildMakepkgCmdCalls = append(m.BuildMakepkgCmdCalls, Call{
|
||||||
Res: []interface{}{res},
|
Res: []any{res},
|
||||||
Args: []interface{}{
|
Args: []any{
|
||||||
ctx,
|
ctx,
|
||||||
dir,
|
dir,
|
||||||
extraArgs,
|
extraArgs,
|
||||||
@@ -103,7 +103,7 @@ func (m *MockBuilder) GetKeepSrc() bool {
|
|||||||
func (m *MockRunner) Capture(cmd *exec.Cmd) (stdout, stderr string, err error) {
|
func (m *MockRunner) Capture(cmd *exec.Cmd) (stdout, stderr string, err error) {
|
||||||
m.CaptureCallsMu.Lock()
|
m.CaptureCallsMu.Lock()
|
||||||
m.CaptureCalls = append(m.CaptureCalls, Call{
|
m.CaptureCalls = append(m.CaptureCalls, Call{
|
||||||
Args: []interface{}{
|
Args: []any{
|
||||||
cmd,
|
cmd,
|
||||||
},
|
},
|
||||||
Dir: cmd.Dir,
|
Dir: cmd.Dir,
|
||||||
@@ -125,7 +125,7 @@ func (m *MockRunner) Show(cmd *exec.Cmd) error {
|
|||||||
|
|
||||||
m.ShowCallsMu.Lock()
|
m.ShowCallsMu.Lock()
|
||||||
m.ShowCalls = append(m.ShowCalls, Call{
|
m.ShowCalls = append(m.ShowCalls, Call{
|
||||||
Args: []interface{}{
|
Args: []any{
|
||||||
cmd,
|
cmd,
|
||||||
},
|
},
|
||||||
Dir: cmd.Dir,
|
Dir: cmd.Dir,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -87,9 +88,7 @@ func (a *Arguments) Copy() (cp *Arguments) {
|
|||||||
|
|
||||||
cp.Op = a.Op
|
cp.Op = a.Op
|
||||||
|
|
||||||
for k, v := range a.Options {
|
maps.Copy(cp.Options, a.Options)
|
||||||
cp.Options[k] = v
|
|
||||||
}
|
|
||||||
|
|
||||||
cp.Targets = make([]string, len(a.Targets))
|
cp.Targets = make([]string, len(a.Targets))
|
||||||
copy(cp.Targets, a.Targets)
|
copy(cp.Targets, a.Targets)
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ func TestOption_Add(t *testing.T) {
|
|||||||
}, want: []string{"c"}},
|
}, want: []string{"c"}},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
o := &Option{
|
o := &Option{
|
||||||
@@ -75,7 +74,6 @@ func TestOption_Set(t *testing.T) {
|
|||||||
}, want: []string{"c"}},
|
}, want: []string{"c"}},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
o := &Option{
|
o := &Option{
|
||||||
@@ -105,7 +103,6 @@ func TestOption_First(t *testing.T) {
|
|||||||
}, want: ""},
|
}, want: ""},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
o := &Option{
|
o := &Option{
|
||||||
@@ -158,7 +155,6 @@ func TestArguments_CopyGlobal(t *testing.T) {
|
|||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
cmdArgs := &Arguments{
|
cmdArgs := &Arguments{
|
||||||
@@ -207,7 +203,6 @@ func TestArguments_Copy(t *testing.T) {
|
|||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
cmdArgs := &Arguments{
|
cmdArgs := &Arguments{
|
||||||
@@ -265,7 +260,6 @@ func TestArguments_FormatArgs(t *testing.T) {
|
|||||||
}, wantArgs: []string{"-Y", "--overwrite", "/tmp/a", "--overwrite", "/tmp/b", "--overwrite", "/tmp/c", "--needed"}},
|
}, wantArgs: []string{"-Y", "--overwrite", "/tmp/a", "--overwrite", "/tmp/b", "--overwrite", "/tmp/c", "--needed"}},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
cmdArgs := &Arguments{
|
cmdArgs := &Arguments{
|
||||||
@@ -313,7 +307,6 @@ func TestArguments_FormatGlobalArgs(t *testing.T) {
|
|||||||
}, wantArgs: []string(nil)},
|
}, wantArgs: []string(nil)},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
cmdArgs := &Arguments{
|
cmdArgs := &Arguments{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package build
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/Jguer/yay/v12/pkg/db"
|
"github.com/Jguer/yay/v12/pkg/db"
|
||||||
@@ -126,9 +127,7 @@ func (installer *Installer) Install(ctx context.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func mergeLayers(layer1, layer2 map[string]*dep.InstallInfo) map[string]*dep.InstallInfo {
|
func mergeLayers(layer1, layer2 map[string]*dep.InstallInfo) map[string]*dep.InstallInfo {
|
||||||
for name, info := range layer2 {
|
maps.Copy(layer1, layer2)
|
||||||
layer1[name] = info
|
|
||||||
}
|
|
||||||
|
|
||||||
return layer1
|
return layer1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ func TestInstaller_InstallNeeded(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(td *testing.T) {
|
t.Run(tc.desc, func(td *testing.T) {
|
||||||
tmpDir := td.TempDir()
|
tmpDir := td.TempDir()
|
||||||
pkgTar := tmpDir + "/yay-91.0.0-1-x86_64.pkg.tar.zst"
|
pkgTar := tmpDir + "/yay-91.0.0-1-x86_64.pkg.tar.zst"
|
||||||
@@ -356,7 +355,6 @@ func TestInstaller_InstallMixedSourcesAndLayers(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(td *testing.T) {
|
t.Run(tc.desc, func(td *testing.T) {
|
||||||
pkgTar := tmpDir + "/yay-91.0.0-1-x86_64.pkg.tar.zst"
|
pkgTar := tmpDir + "/yay-91.0.0-1-x86_64.pkg.tar.zst"
|
||||||
jfinPkgTar := tmpDirJfin + "/jellyfin-server-10.8.8-1-x86_64.pkg.tar.zst"
|
jfinPkgTar := tmpDirJfin + "/jellyfin-server-10.8.8-1-x86_64.pkg.tar.zst"
|
||||||
@@ -561,7 +559,6 @@ func TestInstaller_CompileFailed(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(td *testing.T) {
|
t.Run(tc.desc, func(td *testing.T) {
|
||||||
pkgTar := tmpDir + "/yay-91.0.0-1-x86_64.pkg.tar.zst"
|
pkgTar := tmpDir + "/yay-91.0.0-1-x86_64.pkg.tar.zst"
|
||||||
|
|
||||||
@@ -718,7 +715,6 @@ func TestInstaller_InstallSplitPackage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(td *testing.T) {
|
t.Run(tc.desc, func(td *testing.T) {
|
||||||
pkgTars := []string{
|
pkgTars := []string{
|
||||||
tmpDir + "/jellyfin-10.8.4-1-x86_64.pkg.tar.zst",
|
tmpDir + "/jellyfin-10.8.4-1-x86_64.pkg.tar.zst",
|
||||||
@@ -854,7 +850,6 @@ func TestInstaller_InstallDownloadOnly(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(td *testing.T) {
|
t.Run(tc.desc, func(td *testing.T) {
|
||||||
tmpDir := td.TempDir()
|
tmpDir := td.TempDir()
|
||||||
pkgTar := tmpDir + "/yay-91.0.0-1-x86_64.pkg.tar.zst"
|
pkgTar := tmpDir + "/yay-91.0.0-1-x86_64.pkg.tar.zst"
|
||||||
@@ -979,7 +974,6 @@ func TestInstaller_InstallGroup(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(td *testing.T) {
|
t.Run(tc.desc, func(td *testing.T) {
|
||||||
tmpDir := td.TempDir()
|
tmpDir := td.TempDir()
|
||||||
|
|
||||||
@@ -1176,7 +1170,6 @@ func TestInstaller_InstallRebuild(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(td *testing.T) {
|
t.Run(tc.desc, func(td *testing.T) {
|
||||||
tmpDir := td.TempDir()
|
tmpDir := td.TempDir()
|
||||||
pkgTar := tmpDir + "/yay-91.0.0-1-x86_64.pkg.tar.zst"
|
pkgTar := tmpDir + "/yay-91.0.0-1-x86_64.pkg.tar.zst"
|
||||||
@@ -1294,7 +1287,6 @@ func TestInstaller_InstallUpgrade(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(td *testing.T) {
|
t.Run(tc.desc, func(td *testing.T) {
|
||||||
mockDB := &mock.DBExecutor{}
|
mockDB := &mock.DBExecutor{}
|
||||||
mockRunner := &exe.MockRunner{}
|
mockRunner := &exe.MockRunner{}
|
||||||
@@ -1391,7 +1383,6 @@ func TestInstaller_KeepSrc(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(td *testing.T) {
|
t.Run(tc.desc, func(td *testing.T) {
|
||||||
tmpDir := td.TempDir()
|
tmpDir := td.TempDir()
|
||||||
pkgTar := tmpDir + "/yay-92.0.0-1-x86_64.pkg.tar.zst"
|
pkgTar := tmpDir + "/yay-92.0.0-1-x86_64.pkg.tar.zst"
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ func TestParsePackageList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc // capture range variable
|
// capture range variable
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
@@ -220,7 +220,6 @@ func TestCheckPgpKeys(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range testcases {
|
for _, tt := range testcases {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
mockRunner := &exe.MockRunner{
|
mockRunner := &exe.MockRunner{
|
||||||
ShowFn: tt.showFn,
|
ShowFn: tt.showFn,
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ func Test_downloadPKGBUILDSource(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(td *testing.T) {
|
t.Run(tc.desc, func(td *testing.T) {
|
||||||
cmdBuilder := &TestMakepkgBuilder{
|
cmdBuilder := &TestMakepkgBuilder{
|
||||||
parentBuilder: &exe.CmdBuilder{
|
parentBuilder: &exe.CmdBuilder{
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func (l *Logger) Debugln(a ...any) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
l.Println(append([]interface{}{
|
l.Println(append([]any{
|
||||||
Bold(yellow(fmt.Sprintf("[DEBUG:%s]", l.name))),
|
Bold(yellow(fmt.Sprintf("[DEBUG:%s]", l.name))),
|
||||||
}, a...)...)
|
}, a...)...)
|
||||||
}
|
}
|
||||||
@@ -52,15 +52,15 @@ func (l *Logger) OperationInfo(a ...any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) SprintOperationInfo(a ...any) string {
|
func (l *Logger) SprintOperationInfo(a ...any) string {
|
||||||
return fmt.Sprint(append([]interface{}{Bold(Cyan(opSymbol + " ")), boldCode}, a...)...) + ResetCode
|
return fmt.Sprint(append([]any{Bold(Cyan(opSymbol + " ")), boldCode}, a...)...) + ResetCode
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) Info(a ...any) {
|
func (l *Logger) Info(a ...any) {
|
||||||
l.Print(append([]interface{}{Bold(Green(arrow + " "))}, a...)...)
|
l.Print(append([]any{Bold(Green(arrow + " "))}, a...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) Infoln(a ...any) {
|
func (l *Logger) Infoln(a ...any) {
|
||||||
l.Println(append([]interface{}{Bold(Green(arrow))}, a...)...)
|
l.Println(append([]any{Bold(Green(arrow))}, a...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) Warn(a ...any) {
|
func (l *Logger) Warn(a ...any) {
|
||||||
@@ -72,7 +72,7 @@ func (l *Logger) Warnln(a ...any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) SprintWarn(a ...any) string {
|
func (l *Logger) SprintWarn(a ...any) string {
|
||||||
return fmt.Sprint(append([]interface{}{Bold(yellow(smallArrow + " "))}, a...)...)
|
return fmt.Sprint(append([]any{Bold(yellow(smallArrow + " "))}, a...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) Error(a ...any) {
|
func (l *Logger) Error(a ...any) {
|
||||||
@@ -84,7 +84,7 @@ func (l *Logger) Errorln(a ...any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) SprintError(a ...any) string {
|
func (l *Logger) SprintError(a ...any) string {
|
||||||
return fmt.Sprint(append([]interface{}{Bold(Red(smallArrow + " "))}, a...)...)
|
return fmt.Sprint(append([]any{Bold(Red(smallArrow + " "))}, a...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) Printf(format string, a ...any) {
|
func (l *Logger) Printf(format string, a ...any) {
|
||||||
|
|||||||
@@ -23,10 +23,7 @@ func SplitDBFromName(pkg string) (db, name string) {
|
|||||||
|
|
||||||
// LessRunes compares two rune values, and returns true if the first argument is lexicographicaly smaller.
|
// LessRunes compares two rune values, and returns true if the first argument is lexicographicaly smaller.
|
||||||
func LessRunes(iRunes, jRunes []rune) bool {
|
func LessRunes(iRunes, jRunes []rune) bool {
|
||||||
maxLen := len(iRunes)
|
maxLen := min(len(iRunes), len(jRunes))
|
||||||
if maxLen > len(jRunes) {
|
|
||||||
maxLen = len(jRunes)
|
|
||||||
}
|
|
||||||
|
|
||||||
for idx := 0; idx < maxLen; idx++ {
|
for idx := 0; idx < maxLen; idx++ {
|
||||||
ir := iRunes[idx]
|
ir := iRunes[idx]
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ func TestLessRunes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
got := LessRunes(tt.args.iRunes, tt.args.jRunes)
|
got := LessRunes(tt.args.iRunes, tt.args.jRunes)
|
||||||
|
|||||||
@@ -885,7 +885,6 @@ func TestUpgradeService_GraphUpgrades_zfs_dkms(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
dbExe := &mock.DBExecutor{
|
dbExe := &mock.DBExecutor{
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ func Test_upAUR(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@@ -228,7 +227,6 @@ func Test_upDevel(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
got := UpDevel(context.Background(),
|
got := UpDevel(context.Background(),
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package vcs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/Jguer/go-alpm/v2"
|
"github.com/Jguer/go-alpm/v2"
|
||||||
gosrc "github.com/Morganamilo/go-srcinfo"
|
gosrc "github.com/Morganamilo/go-srcinfo"
|
||||||
@@ -13,12 +14,7 @@ type Mock struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mock) ToUpgrade(ctx context.Context, pkgName string) bool {
|
func (m *Mock) ToUpgrade(ctx context.Context, pkgName string) bool {
|
||||||
for _, pkg := range m.ToUpgradeReturn {
|
return slices.Contains(m.ToUpgradeReturn, pkgName)
|
||||||
if pkg == pkgName {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mock) Update(ctx context.Context, pkgName string, sources []gosrc.ArchString) {
|
func (m *Mock) Update(ctx context.Context, pkgName string, sources []gosrc.ArchString) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -170,14 +171,7 @@ func parseSource(source string) (url, branch string, protocols []string) {
|
|||||||
|
|
||||||
protocols = strings.SplitN(split[0], "+", 2)
|
protocols = strings.SplitN(split[0], "+", 2)
|
||||||
|
|
||||||
git := false
|
git := slices.Contains(protocols, "git")
|
||||||
|
|
||||||
for _, protocol := range protocols {
|
|
||||||
if protocol == "git" {
|
|
||||||
git = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protocols = protocols[len(protocols)-1:]
|
protocols = protocols[len(protocols)-1:]
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ func TestNewInfoStore(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
got := NewInfoStore(tt.args.filePath, tt.args.cmdBuilder,
|
got := NewInfoStore(tt.args.filePath, tt.args.cmdBuilder,
|
||||||
@@ -231,7 +230,6 @@ func TestInfoStoreToUpgrade(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
v := &InfoStore{
|
v := &InfoStore{
|
||||||
@@ -364,7 +362,6 @@ func TestInfoStore_NeedsUpdate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
v := &InfoStore{
|
v := &InfoStore{
|
||||||
@@ -413,7 +410,6 @@ func TestInfoStore_Update(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
v := &InfoStore{
|
v := &InfoStore{
|
||||||
@@ -476,7 +472,6 @@ func TestInfoStore_Remove(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
v := &InfoStore{
|
v := &InfoStore{
|
||||||
@@ -524,7 +519,6 @@ func TestInfoStore_CleanOrphans(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
v := &InfoStore{
|
v := &InfoStore{
|
||||||
|
|||||||
2
print.go
2
print.go
@@ -73,7 +73,7 @@ func biggestPackages(logger *text.Logger, dbExecutor db.Executor) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < 10; i++ {
|
for i := range 10 {
|
||||||
logger.Printf("%s: %s\n", text.Bold(pkgS[i].Name()), text.Cyan(text.Human(pkgS[i].ISize())))
|
logger.Printf("%s: %s\n", text.Bold(pkgS[i].Name()), text.Cyan(text.Human(pkgS[i].ISize())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -630,7 +630,6 @@ func TestSyncUpgrade_NoCombinedUpgrade(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
makepkgBin := t.TempDir() + "/makepkg"
|
makepkgBin := t.TempDir() + "/makepkg"
|
||||||
|
|||||||
Reference in New Issue
Block a user