From f2ba3dfa45b97a6191286434717fd56221a26b9d Mon Sep 17 00:00:00 2001 From: chai2010 Date: Thu, 2 Mar 2023 22:23:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=BD=E4=BB=A4=E8=A1=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=20test=20=E5=AD=90=E5=91=BD=E4=BB=A4=E8=A1=8C=E5=85=A5?= =?UTF-8?q?=E5=8F=A3,=20=E8=BF=98=E6=9C=AA=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/app/app.wa.go | 20 ++++++++++++++++++++ main.go | 7 ++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/internal/app/app.wa.go b/internal/app/app.wa.go index 2b3700a..e24d381 100644 --- a/internal/app/app.wa.go +++ b/internal/app/app.wa.go @@ -184,6 +184,26 @@ func (p *App) InitApp(name, pkgpath string, update bool) error { return nil } +func (p *App) RunTest(path string) error { + if path == "" { + path, _ = os.Getwd() + } + + if strings.HasSuffix(path, "...") { + panic("TODO: test dir/...") + } + + fi, err := os.Lstat(path) + if err != nil { + return err + } + if !fi.IsDir() { + panic("TODO: test path must be dir") + } + + panic("todo") +} + func (p *App) Fmt(path string) error { if path == "" { path, _ = os.Getwd() diff --git a/main.go b/main.go index 09756c5..f04a205 100644 --- a/main.go +++ b/main.go @@ -341,7 +341,12 @@ func main() { Name: "test", Usage: "test packages", Action: func(c *cli.Context) error { - fmt.Println("TODO") + waApp := app.NewApp(build_Options(c)) + err := waApp.RunTest(c.Args().First()) + if err != nil { + fmt.Println(err) + os.Exit(1) + } return nil }, }, -- GitLab