-
Notifications
You must be signed in to change notification settings - Fork 10
/
main_test.go
56 lines (51 loc) · 1.43 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"io/fs"
"os"
"path/filepath"
"strconv"
"testing"
"github.com/ddkwork/golibrary/mylog"
"github.com/ddkwork/golibrary/stream"
)
func TestUpdateAppModule(t *testing.T) {
if !stream.IsDir("D:\\workspace\\workspace\\app") {
return
}
mylog.Check(os.Chdir("D:\\workspace\\workspace\\app"))
session := stream.RunCommand("git log -1 --format=\"%H\"")
mylog.Check(os.Chdir("D:\\workspace\\workspace\\gui"))
id := mylog.Check2(strconv.Unquote(session.Output.String()))
mylog.Info("id", id)
stream.RunCommand("go get github.com/ddkwork/app@" + id)
}
func TestUpdateSDKAndBin(t *testing.T) {
if !stream.IsDir("bin") {
return
}
mylog.Check(os.RemoveAll("bin/debug/SDK/Libraries"))
mylog.Check(os.RemoveAll("sdk/bindgen/SDK"))
mylog.CopyDir("sdk/bindgen/SDK", "bin/debug/SDK")
filepath.Walk("bin", func(path string, info fs.FileInfo, err error) error {
switch filepath.Ext(path) {
case ".exe", ".dll", ".sys":
stream.WriteTruncate(filepath.Join("sdk/bin", filepath.Base(path)), stream.NewBuffer(path))
}
return err
})
mylog.Check(os.RemoveAll("bin"))
}
func TestClearTemp(t *testing.T) {
filepath.Walk(".", func(path string, info fs.FileInfo, err error) error {
ext := filepath.Ext(path)
switch ext {
case ".json", ".txt", ".log":
if filepath.Base(path) == "commands.json" {
return nil
}
mylog.Info("clear file", path)
mylog.Call(func() { mylog.Check(os.Remove(path)) })
}
return err
})
}