Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix gcs test and add to workflow #2277

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/actions/go-setup-and-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ description: "runs setup-go and runs all unit tests in the repo"
runs:
using: composite
steps:
- uses: actions/setup-go@v3
with:
go-version: "^1.19.3"
- name: Run Tests
working-directory: ./
shell: bash
run: "go test ./internal/..."
# should run below, need to fix existing tests
# run: "go test ./backend/... ./internal/... ./pkg/..."
- uses: actions/setup-go@v3
with:
go-version: "^1.21"
- name: Run Tests
working-directory: ./
shell: bash
run: "go test ./internal/... ./pkg/gcs/..."
# should run below, need to fix existing tests
# run: "go test ./backend/... ./internal/... ./pkg/..."
15 changes: 12 additions & 3 deletions pkg/gcs/eval_fn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestFib(t *testing.T) {
resultChan <- res
}()
for {
eval.Continue()
a, err := eval.NextAction()
if a == nil {
break
Expand Down Expand Up @@ -90,6 +91,7 @@ func TestFunctional(t *testing.T) {
resultChan <- res
}()
for {
eval.Continue()
a, err := eval.NextAction()
if a == nil {
break
Expand Down Expand Up @@ -137,6 +139,7 @@ func TestAnonFunc(t *testing.T) {
resultChan <- res
}()
for {
eval.Continue()
a, err := eval.NextAction()
if a == nil {
break
Expand Down Expand Up @@ -184,6 +187,7 @@ func TestStringFunc(t *testing.T) {
resultChan <- res
}()
for {
eval.Continue()
a, err := eval.NextAction()
if a == nil {
break
Expand Down Expand Up @@ -214,7 +218,7 @@ func TestStringFunc(t *testing.T) {
func TestNestedActions(t *testing.T) {
prog := `
fn do() {
xingqiu attack;
print("hi");
}
do();
`
Expand All @@ -231,9 +235,13 @@ func TestNestedActions(t *testing.T) {
go func() {
res, err := eval.Run()
fmt.Printf("done with result: %v, err: %v\n", res, err)
if err != nil {
log.Fatalf("test run failed with error: %v", err)
}
resultChan <- res
}()
for {
eval.Continue()
a, err := eval.NextAction()
if a == nil {
break
Expand All @@ -243,8 +251,9 @@ func TestNestedActions(t *testing.T) {
}
}
result := <-resultChan
if result.Typ() != typNull {
t.Errorf("expecting type to return null, got %v", typStrings[result.Typ()])
// by default, functions return num
if result.Typ() != typNum {
t.Errorf("expecting type to return num, got %v", typStrings[result.Typ()])
}
if eval.Err() != nil {
t.Error(eval.Err())
Expand Down
12 changes: 10 additions & 2 deletions pkg/gcs/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestType(t *testing.T) {
resultChan <- res
}()
for {
eval.Continue()
a, err := eval.NextAction()
if a == nil {
break
Expand All @@ -43,7 +44,10 @@ func TestType(t *testing.T) {

func TestForceTerminate(t *testing.T) {
// test terminate eval early should gracefully exit
p := ast.New("xingqiu attack:50;")
p := ast.New(`
for let i = 0; i < 50; i = i + 1 {
delay(1);
}`)
_, gcsl, err := p.Parse()
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -101,6 +105,7 @@ func TestSleepAsWaitAlias(t *testing.T) {
res, err := eval.Run()
fmt.Printf("done with result: %v, err: %v\n", res, err)
}()
eval.Continue()
a, err := eval.NextAction()
if err != nil {
t.Errorf("unexpected error getting next action: %v", err)
Expand All @@ -124,7 +129,10 @@ func TestSleepAsWaitAlias(t *testing.T) {

func TestDoneCheck(t *testing.T) {
// eval should exit once out of action; NextAction() should return nil
p := ast.New("xingqiu attack, attack, skill, burst;")
p := ast.New(`
for let i = 0; i < 4; i = i + 1 {
delay(1);
}`)
_, gcsl, err := p.Parse()
if err != nil {
t.Fatal(err)
Expand Down
Loading