-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcherri_test.go
118 lines (102 loc) · 2.33 KB
/
cherri_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* Copyright (c) Cherri
*/
package main
import (
"encoding/json"
"fmt"
"github.com/electrikmilk/args-parser"
"os"
"strings"
"testing"
"time"
)
var currentTest string
func TestCherri(_ *testing.T) {
args.Args["no-ansi"] = ""
var files, err = os.ReadDir("tests")
if err != nil {
fmt.Println(ansi("FAILED: unable to read tests directory", red))
panic(err)
}
for _, file := range files {
if !strings.Contains(file.Name(), ".cherri") {
continue
}
currentTest = fmt.Sprintf("tests/%s", file.Name())
os.Args[1] = currentTest
fmt.Println(ansi(currentTest, underline, bold))
compile()
fmt.Println(ansi("✅ PASSED", green, bold))
fmt.Print("\n")
resetParser()
if signFailed {
fmt.Println(ansi("Using remote service HubSign", cyan, bold))
for i := 5; i > 0; i-- {
fmt.Print(ansi(fmt.Sprintf("Respectfully waiting %d second(s) between tests...\r", i), cyan))
time.Sleep(1 * time.Second)
}
fmt.Print("\n")
}
}
}
func TestCherriNoSign(t *testing.T) {
args.Args["skip-sign"] = ""
TestCherri(t)
}
func TestSingleFile(_ *testing.T) {
currentTest = "tests/conditionals.cherri"
fmt.Printf("⚙️ Compiling %s...\n", ansi(currentTest, bold))
os.Args[1] = currentTest
main()
fmt.Print(ansi("✅ PASSED", green, bold) + "\n\n")
}
func TestActionList(_ *testing.T) {
for identifier := range actions {
fmt.Println("{label: '" + identifier + "', type: 'function', detail: 'action'},")
}
}
func TestGlyphList(_ *testing.T) {
var data, jsonErr = json.Marshal(glyphs)
handle(jsonErr)
fmt.Println(string(data))
}
func compile() {
defer func() {
if recover() != nil {
panicDebug(nil)
}
}()
main()
}
func resetParser() {
lines = []string{}
chars = []rune{}
char = -1
idx = 0
lineIdx = 0
lineCharIdx = 0
groupingUUIDs = map[int]string{}
groupingTypes = map[int]tokenType{}
groupingIdx = 0
variables = map[string]variableValue{}
iconColor = -1263359489
iconGlyph = 61440
clientVersion = "900"
iosVersion = 16.5
questions = map[string]*question{}
hasShortcutInputVariables = false
tabLevel = 0
types = []string{}
inputs = []string{}
outputs = []string{}
noInput = noInputParams{}
tokens = []token{}
included = []string{}
includes = []include{}
workflowName = ""
plist.Reset()
menus = map[string][]variableValue{}
uuids = map[string]string{}
customActions = map[string]*customAction{}
}