mirror of
https://github.com/awalsh128/cache-apt-pkgs-action.git
synced 2025-12-29 06:41:30 +00:00
Fix virtual package parsing issue and add test case
Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>
This commit is contained in:
parent
1a07661c6e
commit
60332806e6
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
|||
src/cmd/apt_query/apt_query*
|
||||
src/cmd/apt_query/apt_query*
|
||||
apt_query_test*
|
||||
BIN
apt_query_test
BIN
apt_query_test
Binary file not shown.
|
|
@ -68,3 +68,10 @@ func TestNormalizedList_VirtualPackagesExists_StdoutsConcretePackage(t *testing.
|
|||
result := cmdtesting.New(t, createReplayLogs).Run("normalized-list", "libvips")
|
||||
result.ExpectSuccessfulOut("libvips42=8.9.1-2")
|
||||
}
|
||||
|
||||
func TestNormalizedList_VirtualPackageWithNoProviders_StderrsErrorMessage(t *testing.T) {
|
||||
var result = cmdtesting.New(t, createReplayLogs).Run("normalized-list", "python")
|
||||
result.ExpectError(`Encountered error resolving some or all package names, see combined std[out,err] below.
|
||||
virtual package 'python' has no concrete package providers
|
||||
virtual package 'python' has no concrete package providers`)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
2025/09/30 07:33:25 Debug log created at /home/runner/work/cache-apt-pkgs-action/cache-apt-pkgs-action/src/cmd/apt_query/apt_query.log
|
||||
2025/09/30 07:33:26 EXECUTION-OBJ-START
|
||||
{
|
||||
"Cmd": "apt-cache --quiet=0 --no-all-versions show python",
|
||||
"CombinedOut": "N: Can't select candidate version from package python as it has no candidate\nN: Can't select versions from package 'python' as it is purely virtual\nN: No packages found\n",
|
||||
"ExitCode": 0
|
||||
}
|
||||
EXECUTION-OBJ-END
|
||||
2025/09/30 07:33:27 EXECUTION-OBJ-START
|
||||
{
|
||||
"Cmd": "bash -c apt-cache showpkg python | grep -A 1 \"Reverse Provides\" | tail -1",
|
||||
"CombinedOut": "Reverse Provides: \n",
|
||||
"ExitCode": 0
|
||||
}
|
||||
EXECUTION-OBJ-END
|
||||
2025/09/30 07:33:27 Encountered error resolving some or all package names, see combined std[out,err] below.
|
||||
virtual package 'python' has no concrete package providers
|
||||
virtual package 'python' has no concrete package providers
|
||||
|
|
@ -42,6 +42,13 @@ func getNonVirtualPackage(executor exec.Executor, name string) (pkg *AptPackage,
|
|||
if isErrLine(execution.CombinedOut) {
|
||||
return pkg, execution.Error()
|
||||
}
|
||||
|
||||
// Check if the output is just "Reverse Provides:" with no actual package info
|
||||
trimmedOutput := strings.TrimSpace(execution.CombinedOut)
|
||||
if trimmedOutput == "Reverse Provides:" {
|
||||
return pkg, fmt.Errorf("virtual package '%s' has no concrete package providers", name)
|
||||
}
|
||||
|
||||
splitLine := GetSplitLine(execution.CombinedOut, " ", 3)
|
||||
if len(splitLine.Words) < 2 {
|
||||
return pkg, fmt.Errorf("unable to parse space delimited line's package name and version from apt-cache showpkg output below:\n%s", execution.CombinedOut)
|
||||
|
|
|
|||
Loading…
Reference in a new issue