-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
308 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. | ||
// | ||
// This Source Code Form is subject to the terms of the MIT License. | ||
// If a copy of the MIT was not distributed with this file, | ||
// You can obtain one at https://github.com/gogf/gf. | ||
|
||
package cmd | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gogf/gf/v2/os/gfile" | ||
"github.com/gogf/gf/v2/os/gproc" | ||
"github.com/gogf/gf/v2/test/gtest" | ||
"github.com/gogf/gf/v2/text/gstr" | ||
) | ||
|
||
func Test_Build_Single(t *testing.T) { | ||
gtest.C(t, func(t *gtest.T) { | ||
var ( | ||
buildPath = gtest.DataPath(`build`, `single`) | ||
pwd = gfile.Pwd() | ||
binaryName = `t.test` | ||
binaryPath = gtest.DataPath(`build`, `single`, binaryName) | ||
f = cBuild{} | ||
) | ||
defer gfile.Chdir(pwd) | ||
defer gfile.Remove(binaryPath) | ||
err := gfile.Chdir(buildPath) | ||
t.AssertNil(err) | ||
|
||
t.Assert(gfile.Exists(binaryPath), false) | ||
_, err = f.Index(ctx, cBuildInput{ | ||
File: cBuildDefaultFile, | ||
Name: binaryName, | ||
}) | ||
t.AssertNil(err) | ||
t.Assert(gfile.Exists(binaryPath), true) | ||
}) | ||
} | ||
|
||
func Test_Build_Single_Output(t *testing.T) { | ||
gtest.C(t, func(t *gtest.T) { | ||
var ( | ||
buildPath = gtest.DataPath(`build`, `single`) | ||
pwd = gfile.Pwd() | ||
binaryName = `tt` | ||
binaryDirPath = gtest.DataPath(`build`, `single`, `tt`) | ||
binaryPath = gtest.DataPath(`build`, `single`, `tt`, binaryName) | ||
f = cBuild{} | ||
) | ||
defer gfile.Chdir(pwd) | ||
defer gfile.Remove(binaryDirPath) | ||
err := gfile.Chdir(buildPath) | ||
t.AssertNil(err) | ||
|
||
t.Assert(gfile.Exists(binaryPath), false) | ||
_, err = f.Index(ctx, cBuildInput{ | ||
Output: "./tt/tt", | ||
}) | ||
t.AssertNil(err) | ||
t.Assert(gfile.Exists(binaryPath), true) | ||
}) | ||
} | ||
|
||
func Test_Build_Single_Path(t *testing.T) { | ||
gtest.C(t, func(t *gtest.T) { | ||
var ( | ||
buildPath = gtest.DataPath(`build`, `single`) | ||
pwd = gfile.Pwd() | ||
dirName = "ttt" | ||
binaryName = `main` | ||
binaryDirPath = gtest.DataPath(`build`, `single`, dirName) | ||
binaryPath = gtest.DataPath(`build`, `single`, dirName, binaryName) | ||
f = cBuild{} | ||
) | ||
defer gfile.Chdir(pwd) | ||
defer gfile.Remove(binaryDirPath) | ||
err := gfile.Chdir(buildPath) | ||
t.AssertNil(err) | ||
|
||
t.Assert(gfile.Exists(binaryPath), false) | ||
_, err = f.Index(ctx, cBuildInput{ | ||
Path: "ttt", | ||
}) | ||
t.AssertNil(err) | ||
t.Assert(gfile.Exists(binaryPath), true) | ||
}) | ||
} | ||
|
||
func Test_Build_Single_VarMap(t *testing.T) { | ||
gtest.C(t, func(t *gtest.T) { | ||
var ( | ||
buildPath = gtest.DataPath(`build`, `varmap`) | ||
pwd = gfile.Pwd() | ||
binaryName = `main` | ||
binaryPath = gtest.DataPath(`build`, `varmap`, binaryName) | ||
f = cBuild{} | ||
) | ||
defer gfile.Chdir(pwd) | ||
defer gfile.Remove(binaryPath) | ||
err := gfile.Chdir(buildPath) | ||
t.AssertNil(err) | ||
|
||
t.Assert(gfile.Exists(binaryPath), false) | ||
_, err = f.Index(ctx, cBuildInput{ | ||
VarMap: map[string]interface{}{ | ||
"a": "1", | ||
"b": "2", | ||
}, | ||
}) | ||
t.AssertNil(err) | ||
t.Assert(gfile.Exists(binaryPath), true) | ||
|
||
result, err := gproc.ShellExec(ctx, binaryPath) | ||
t.AssertNil(err) | ||
t.Assert(gstr.Contains(result, `a: 1`), true) | ||
t.Assert(gstr.Contains(result, `b: 2`), true) | ||
}) | ||
} | ||
|
||
func Test_Build_Multiple(t *testing.T) { | ||
gtest.C(t, func(t *gtest.T) { | ||
var ( | ||
buildPath = gtest.DataPath(`build`, `multiple`) | ||
pwd = gfile.Pwd() | ||
binaryDirPath = gtest.DataPath(`build`, `multiple`, `temp`) | ||
binaryPathLinux = gtest.DataPath(`build`, `multiple`, `temp`, `v1.1`, `linux_amd64`, `ttt`) | ||
binaryPathWindows = gtest.DataPath(`build`, `multiple`, `temp`, `v1.1`, `windows_amd64`, `ttt.exe`) | ||
f = cBuild{} | ||
) | ||
defer gfile.Chdir(pwd) | ||
defer gfile.Remove(binaryDirPath) | ||
err := gfile.Chdir(buildPath) | ||
t.AssertNil(err) | ||
|
||
t.Assert(gfile.Exists(binaryPathLinux), false) | ||
t.Assert(gfile.Exists(binaryPathWindows), false) | ||
_, err = f.Index(ctx, cBuildInput{ | ||
File: "multiple.go", | ||
Name: "ttt", | ||
Version: "v1.1", | ||
Arch: "amd64", | ||
System: "linux, windows", | ||
Path: "temp", | ||
}) | ||
t.AssertNil(err) | ||
t.Assert(gfile.Exists(binaryPathLinux), true) | ||
t.Assert(gfile.Exists(binaryPathWindows), true) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package main | ||
|
||
func main() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package main | ||
|
||
func main() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module github.com/gogf/gf/cmd/gf/cmd/gf/testdata/vardump/v2 | ||
|
||
go 1.18 | ||
|
||
require github.com/gogf/gf/v2 v2.6.1 | ||
|
||
require ( | ||
go.opentelemetry.io/otel v1.14.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.14.0 // indirect | ||
) | ||
|
||
replace github.com/gogf/gf/v2 => ../../../../../../../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= | ||
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= | ||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= | ||
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= | ||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= | ||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= | ||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= | ||
github.com/grokify/html-strip-tags-go v0.0.1 h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q/MOnCQxKMo0= | ||
github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= | ||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= | ||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= | ||
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= | ||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= | ||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= | ||
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM= | ||
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= | ||
go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY= | ||
go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M= | ||
go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8= | ||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= | ||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= | ||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= |
Oops, something went wrong.