Skip to content

Commit

Permalink
fix: fix logWriter missing in KpmClient
Browse files Browse the repository at this point in the history
Signed-off-by: zongz <zongzhe1024@163.com>
  • Loading branch information
zong-zhe committed Apr 29, 2024
1 parent f3e75d9 commit 108ecaf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ func (c *KpmClient) CompileWithOpts(opts *opt.CompileOptions) (*kcl.KCLResultLis
}

c.noSumCheck = opts.NoSumCheck()
c.logWriter = opts.LogWriter()

kclPkg, err := c.LoadPkgFromPath(pkgPath)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion pkg/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1480,12 +1480,16 @@ func TestRunWithOciDownloader(t *testing.T) {

kpmCli.DepDownloader = downloader.NewOciDownloader("linux/amd64")

var buf bytes.Buffer
writer := io.MultiWriter(&buf, os.Stdout)

res, err := kpmCli.RunWithOpts(
opt.WithEntries([]string{filepath.Join(path, "run_pkg", "pkg", "main.k")}),
opt.WithKclOption(kcl.WithWorkDir(filepath.Join(path, "run_pkg", "pkg"))),
opt.WithNoSumCheck(true),
opt.WithLogWriter(nil),
opt.WithLogWriter(writer),
)
assert.Equal(t, err, nil)
assert.Equal(t, buf.String(), "downloading 'zong-zhe/helloworld:0.0.3' from 'ghcr.io/zong-zhe/helloworld:0.0.3'\n")
assert.Equal(t, res.GetRawYamlResult(), "The_first_kcl_program: Hello World!")
}

0 comments on commit 108ecaf

Please sign in to comment.