v0.0.344
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m11s
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 1m11s
This commit is contained in:
parent
5dad44ad09
commit
8247fc4524
@ -61,11 +61,15 @@ func GenerateEnumSpecs(sourceDir string, destFile string) error {
|
||||
}
|
||||
}
|
||||
|
||||
gocode, _, err := _generateEnumSpecs(sourceDir, destFile, oldChecksum, true)
|
||||
gocode, _, changed, err := _generateEnumSpecs(sourceDir, destFile, oldChecksum, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if changed {
|
||||
return nil
|
||||
}
|
||||
|
||||
err = os.WriteFile(destFile, []byte(gocode), 0o755)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -74,11 +78,11 @@ func GenerateEnumSpecs(sourceDir string, destFile string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func _generateEnumSpecs(sourceDir string, destFile string, oldChecksum string, gofmt bool) (string, string, error) {
|
||||
func _generateEnumSpecs(sourceDir string, destFile string, oldChecksum string, gofmt bool) (string, string, bool, error) {
|
||||
|
||||
files, err := os.ReadDir(sourceDir)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
return "", "", false, err
|
||||
}
|
||||
|
||||
files = langext.ArrFilter(files, func(v os.DirEntry) bool { return v.Name() != path.Base(destFile) })
|
||||
@ -90,7 +94,7 @@ func _generateEnumSpecs(sourceDir string, destFile string, oldChecksum string, g
|
||||
for _, f := range files {
|
||||
content, err := os.ReadFile(path.Join(sourceDir, f.Name()))
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
return "", "", false, err
|
||||
}
|
||||
newChecksumStr += "\n" + f.Name() + "\t" + cryptext.BytesSha256(content)
|
||||
}
|
||||
@ -101,7 +105,7 @@ func _generateEnumSpecs(sourceDir string, destFile string, oldChecksum string, g
|
||||
fmt.Printf("[EnumGenerate] Checksum has changed ( %s -> %s ), will generate new file\n\n", oldChecksum, newChecksum)
|
||||
} else {
|
||||
fmt.Printf("[EnumGenerate] Checksum unchanged ( %s ), nothing to do\n", oldChecksum)
|
||||
return "", oldChecksum, nil
|
||||
return "", oldChecksum, false, nil
|
||||
}
|
||||
|
||||
allEnums := make([]EnumDef, 0)
|
||||
@ -112,7 +116,7 @@ func _generateEnumSpecs(sourceDir string, destFile string, oldChecksum string, g
|
||||
fmt.Printf("========= %s =========\n\n", f.Name())
|
||||
fileEnums, pn, err := processEnumFile(sourceDir, path.Join(sourceDir, f.Name()))
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
return "", "", false, err
|
||||
}
|
||||
|
||||
fmt.Printf("\n")
|
||||
@ -125,21 +129,21 @@ func _generateEnumSpecs(sourceDir string, destFile string, oldChecksum string, g
|
||||
}
|
||||
|
||||
if pkgname == "" {
|
||||
return "", "", errors.New("no package name found in any file")
|
||||
return "", "", false, errors.New("no package name found in any file")
|
||||
}
|
||||
|
||||
rdata := fmtEnumOutput(newChecksum, allEnums, pkgname)
|
||||
|
||||
if !gofmt {
|
||||
return rdata, newChecksum, nil
|
||||
return rdata, newChecksum, true, nil
|
||||
}
|
||||
|
||||
fdata, err := format.Source([]byte(rdata))
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
return "", "", false, err
|
||||
}
|
||||
|
||||
return string(fdata), newChecksum, nil
|
||||
return string(fdata), newChecksum, true, nil
|
||||
}
|
||||
|
||||
func processEnumFile(basedir string, fn string) ([]EnumDef, string, error) {
|
||||
|
@ -37,10 +37,10 @@ func TestGenerateEnumSpecs(t *testing.T) {
|
||||
_, err = cmdext.Runner("tar").Arg("-xvzf").Arg(tmpFile).Arg("-C").Arg(tmpDir).FailOnExitCode().FailOnTimeout().Timeout(time.Minute).Run()
|
||||
tst.AssertNoErr(t, err)
|
||||
|
||||
s1, cs1, err := _generateEnumSpecs(tmpDir, "", "N/A", true)
|
||||
s1, cs1, _, err := _generateEnumSpecs(tmpDir, "", "N/A", true)
|
||||
tst.AssertNoErr(t, err)
|
||||
|
||||
s2, cs2, err := _generateEnumSpecs(tmpDir, "", "N/A", true)
|
||||
s2, cs2, _, err := _generateEnumSpecs(tmpDir, "", "N/A", true)
|
||||
tst.AssertNoErr(t, err)
|
||||
|
||||
tst.AssertEqual(t, cs1, cs2)
|
||||
@ -76,7 +76,7 @@ func TestGenerateEnumSpecsData(t *testing.T) {
|
||||
_, err = cmdext.Runner("tar").Arg("-xvzf").Arg(tmpFile).Arg("-C").Arg(tmpDir).FailOnExitCode().FailOnTimeout().Timeout(time.Minute).Run()
|
||||
tst.AssertNoErr(t, err)
|
||||
|
||||
s1, _, err := _generateEnumSpecs(tmpDir, "", "", true)
|
||||
s1, _, _, err := _generateEnumSpecs(tmpDir, "", "", true)
|
||||
tst.AssertNoErr(t, err)
|
||||
|
||||
fmt.Println()
|
||||
|
@ -1,5 +1,5 @@
|
||||
package goext
|
||||
|
||||
const GoextVersion = "0.0.343"
|
||||
const GoextVersion = "0.0.344"
|
||||
|
||||
const GoextVersionTimestamp = "2023-12-07T18:29:17+0100"
|
||||
const GoextVersionTimestamp = "2023-12-07T19:36:21+0100"
|
||||
|
Loading…
Reference in New Issue
Block a user