Skip to content

Commit

Permalink
remote not support os and arch from y2jBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
bronze1man committed Jul 24, 2023
1 parent a4da28f commit 6d1a8ae
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 30 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ yaml2json

# goland files
.idea/
/bin
/bin
/tmp
96 changes: 67 additions & 29 deletions y2jBuilder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"strings"
"path/filepath"
"runtime"
"io/ioutil"
"archive/zip"
"bytes"
Expand All @@ -21,39 +20,41 @@ func main(){
goos string
goarch string
}
buildInfoList := []buildInfo{
{"darwin","386"},
{"darwin","amd64"},
{"linux","386"},
{"linux","amd64"},
{"linux","arm"},
{"windows","386"},
{"windows","amd64"},
{"freebsd","386"},
{"freebsd","amd64"},
{"freebsd","arm"},
{"netbsd","386"},
{"netbsd","amd64"},
{"netbsd","arm"},
{"openbsd","386"},
{"openbsd","amd64"},
{"plan9","386"},
{"linux","ppc64le"},
buildInfoList := []buildInfo{}
for _,line:= range strings.Split(osAndArchList,"\n"){
line = strings.TrimSpace(line)
if line==``{
continue
}
part:=strings.Split(line,"/")
buildInfoList = append(buildInfoList,buildInfo{goos: part[0],goarch: part[1]})
}
//buildInfoList := []buildInfo{
// {"darwin","amd64"},
// {"linux","386"},
// {"linux","amd64"},
// {"linux","arm"},
// {"windows","386"},
// {"windows","amd64"},
// {"freebsd","386"},
// {"freebsd","amd64"},
// {"freebsd","arm"},
// {"netbsd","386"},
// {"netbsd","amd64"},
// {"netbsd","arm"},
// {"openbsd","386"},
// {"openbsd","amd64"},
// {"plan9","386"},
// {"linux","ppc64le"},
//}
for _,info:=range buildInfoList{
mustRunCmd([]string{"go","install","-ldflags","-s -w","-gcflags=-trimpath="+gopath,"github.com/bronze1man/yaml2json"},map[string]string{
"GOOS":info.goos,
"GOARCH":info.goarch,
})
var outputPath string
if info.goarch == runtime.GOARCH && info.goos == runtime.GOOS{
outputPath = filepath.Join(gopath,"bin","yaml2json")
}else{
outputPath = filepath.Join(gopath,"bin",info.goos+"_"+info.goarch,"yaml2json")
}
outputPath := filepath.Join(gopath,"bin",info.goos+"_"+info.goarch,"yaml2json")
if info.goos=="windows"{
outputPath+=".exe"
}
mustRunCmd([]string{"go","build","-o",outputPath,"-ldflags","-s -w","-gcflags=-trimpath","github.com/bronze1man/yaml2json"},map[string]string{
"GOOS":info.goos,
})
filePath:="yaml2json_"+info.goos+"_"+info.goarch
if info.goos=="windows"{
filePath+=".exe"
Expand All @@ -68,6 +69,43 @@ func main(){
mustZipDir(filepath.Join(gopath,"tmp","fileZip"),filepath.Join(gopath,"tmp","file","yaml2json_all.zip"))
}

const osAndArchList = `darwin/amd64
darwin/arm64
dragonfly/amd64
freebsd/386
freebsd/amd64
freebsd/arm
freebsd/arm64
illumos/amd64
linux/386
linux/amd64
linux/arm
linux/arm64
linux/mips
linux/mips64
linux/mips64l
linux/mipsle
linux/ppc64
linux/ppc64le
linux/riscv64
linux/s390x
netbsd/386
netbsd/amd64
netbsd/arm
netbsd/arm64
openbsd/386
openbsd/amd64
openbsd/arm
openbsd/arm64
openbsd/mips6
plan9/386
plan9/amd64
plan9/arm
solaris/amd64
windows/386
windows/amd64
windows/arm
windows/arm64`
func mustCopyFile(fromPath string,toPath string){
content,err:=ioutil.ReadFile(fromPath)
if err!=nil{
Expand Down
10 changes: 10 additions & 0 deletions y2jLib/Translate2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package y2jLib

import "io"

type Translate2Req struct {
In io.Reader
Out io.Writer
MultiDocumentAsJsonArray bool // https://github.com/bronze1man/yaml2json/issues/19

}
File renamed without changes.
32 changes: 32 additions & 0 deletions y2jLib/lib_test.go → y2jLib/TranslateStream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,43 @@ key5: Document`,`{"key1":"+Inf","key2":"NaN","key3":null}
y:`,`{"x":null,"y":null}
`,
}, // https://github.com/bronze1man/yaml2json/issues/15
{
`first:
file: without --- at top
---
second:
file: which is actually the last one
next: there's nothing after the last delimiter
---`,
`{"first":{"file":"without --- at top"}}
{"second":{"file":"which is actually the last one","next":"there's nothing after the last delimiter"}}
null
`,
},
{
`properties:
property1: FOO
property2:`,
`{"properties":{"property1":"FOO","property2":null}}
`,
}, // https://github.com/bronze1man/yaml2json/issues/23
}
for _,cas:=range casList{
out:=mustTranslateStreamString(cas.in)
if out!=cas.out{
panic("fail in:["+cas.in+"] thisOut:["+string(out)+"] expect:["+cas.out+"]")
}
}
}

func FuzzTranslateStreamNoPanic(f *testing.F) {
testcases := []string{`5.6: 5.6`,`m: false`}
for _, tc := range testcases {
f.Add(tc) // Use f.Add to provide a seed corpus
}
f.Fuzz(func(t *testing.T, orig string) {
inBuf:=bytes.NewBufferString(orig)
outBuf:=&bytes.Buffer{}
_ = TranslateStream(inBuf,outBuf)
})
}

0 comments on commit 6d1a8ae

Please sign in to comment.