Skip to content

Commit

Permalink
Add ntt-show dumb mode
Browse files Browse the repository at this point in the history
  • Loading branch information
5nord committed Oct 24, 2024
1 parent 23f8d22 commit e3f8306
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ var (

verbose int
ShSetup bool
dumb bool
outputQuiet bool
outputJSON bool
outputPlain bool
Expand Down Expand Up @@ -145,6 +146,7 @@ func init() {
root.AddCommand(T3xfasmCommand)

ShowCommand.PersistentFlags().BoolVarP(&ShSetup, "sh", "", false, "output test suite data for shell consumption")
ShowCommand.PersistentFlags().BoolVarP(&dumb, "dumb", "", false, "do not evaluate testcase configuration")
}

func Format() string {
Expand Down
54 changes: 28 additions & 26 deletions show.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,36 +76,38 @@ func printJSON(report *ConfigReport, keys []string) error {
return err
}

var list []project.TestConfig
for _, file := range files {
tree := ttcn3.ParseFile(file)
if tree.Err != nil {
report.err = errors.Join(report.err, tree.Err)
}
tree.Inspect(func(n syntax.Node) bool {
switch n := n.(type) {
case *syntax.FuncDecl:
if n.IsTest() || n.IsControl() {
if dumb {
var list []project.TestConfig
for _, file := range files {
tree := ttcn3.ParseFile(file)
if tree.Err != nil {
report.err = errors.Join(report.err, tree.Err)
}
tree.Inspect(func(n syntax.Node) bool {
switch n := n.(type) {
case *syntax.FuncDecl:
if n.IsTest() || n.IsControl() {
break
}
return false
case *syntax.ControlPart:
break
default:
return true
}
name := tree.QualifiedName(n)
tc, err := report.TestConfigs(name, presets...)
if err != nil {
log.Debugf("implementation error: %s\n", err)
}
if len(tc) > 0 {
list = append(list, tc...)
}
return false
case *syntax.ControlPart:
break
default:
return true
}
name := tree.QualifiedName(n)
tc, err := report.TestConfigs(name, presets...)
if err != nil {
log.Debugf("implementation error: %s\n", err)
}
if len(tc) > 0 {
list = append(list, tc...)
}
return false
})
})
}
report.Execute = list
}
report.Execute = list

b, err := yaml.MarshalJSON(report)
if err != nil {
Expand Down

0 comments on commit e3f8306

Please sign in to comment.