Skip to content

Commit

Permalink
fix sub test traces
Browse files Browse the repository at this point in the history
  • Loading branch information
xhd2015 committed Apr 14, 2024
1 parent b70bf6d commit b0dd187
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 144 deletions.
6 changes: 3 additions & 3 deletions cmd/xgo/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Usage:
xgo <command> [arguments]
The commands are:
build build instrumented code, extra arguments are passed 'go build' verbatim
run run instrumented code, extra arguments are passed 'go run' verbatim
test test instrumented code, extra arguments are passed 'go test' verbatim
build build instrumented code, extra arguments are passed to 'go build' verbatim
run run instrumented code, extra arguments are passed to 'go run' verbatim
test test instrumented code, extra arguments are passed to 'go test' verbatim
exec execute a command verbatim
version print xgo version
revision print xgo revision
Expand Down
6 changes: 3 additions & 3 deletions cmd/xgo/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package main

import "fmt"

const VERSION = "1.0.23"
const REVISION = "e8daf6b3b430f0be7a30aa02bf0f8334c93537ec+1"
const NUMBER = 178
const VERSION = "1.0.24"
const REVISION = "b70bf6dce3af4317cb6a3b2b18dc30e2b36b8afa+1"
const NUMBER = 179

func getRevision() string {
revSuffix := ""
Expand Down
6 changes: 3 additions & 3 deletions runtime/core/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"os"
)

const VERSION = "1.0.23"
const REVISION = "e8daf6b3b430f0be7a30aa02bf0f8334c93537ec+1"
const NUMBER = 178
const VERSION = "1.0.24"
const REVISION = "b70bf6dce3af4317cb6a3b2b18dc30e2b36b8afa+1"
const NUMBER = 179

// these fields will be filled by compiler
const XGO_VERSION = ""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package trace_marshal_with_trace

import (
"fmt"
"testing"

"github.com/xhd2015/xgo/runtime/trace"
)

func TestMarshalWithTrace(t *testing.T) {
const N = 10
traces := make([]*trace.Root, N)
for i := 0; i < 10; i++ {
i := i
t.Run(fmt.Sprintf("case_%d", i), func(t *testing.T) {
finish := trace.Options().OnComplete(func(root *trace.Root) {
traces[i] = root
}).Begin()
defer finish()
res := foo(i)

expect := fmt.Sprintf("foo bar_%d", i)
if res != expect {
t.Fatalf("expect %q, actual: %q", expect, res)
}
})
}
// each should have children
for i, tr := range traces {
if len(tr.Children) != 1 {
t.Fatalf("expect traces[%d] children len to be %d, actual: %d", i, 1, len(tr.Children))
}
}
}

func foo(i int) string {
return "foo " + bar(i)
}
func bar(i int) string {
return fmt.Sprintf("bar_%d", i)
}
Loading

0 comments on commit b0dd187

Please sign in to comment.