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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
use super::ParamValue;
use super::{BinType, FlowCondition, FlowID, GroupType, PatternGroupType};
use crate::generator::ast::Meta;
use crate::testers::SupportedTester;
use crate::{Result, FLOW};
pub fn start_sub_flow(name: &str, meta: Option<Meta>) -> Result<usize> {
let n = node!(PGMSubFlow, name.to_owned(); meta);
FLOW.push_and_open(n)
}
pub fn end_block(ref_id: usize) -> Result<()> {
FLOW.close(ref_id)
}
pub fn define_test(
name: &str,
tester: &SupportedTester,
lib_name: &str,
template_name: &str,
meta: Option<Meta>,
) -> Result<usize> {
let id = crate::STATUS.generate_unique_id();
let n = node!(PGMDefTest, id, name.to_owned(), tester.to_owned(), lib_name.to_owned(), template_name.to_owned(); meta);
FLOW.push(n)?;
Ok(id)
}
pub fn define_test_invocation(
name: &str,
tester: &SupportedTester,
meta: Option<Meta>,
) -> Result<usize> {
let id = crate::STATUS.generate_unique_id();
let n = node!(PGMDefTestInv, id, name.to_owned(), tester.to_owned(); meta);
FLOW.push(n)?;
Ok(id)
}
pub fn set_test_attr(id: usize, name: &str, value: ParamValue, meta: Option<Meta>) -> Result<()> {
let n = node!(PGMSetAttr, id, name.to_owned(), value; meta);
FLOW.push(n)?;
Ok(())
}
pub fn assign_test_to_invocation(
invocation_id: usize,
test_id: usize,
meta: Option<Meta>,
) -> Result<()> {
let n = node!(PGMAssignTestToInv, invocation_id, test_id; meta);
FLOW.push(n)?;
Ok(())
}
pub fn execute_test(id: usize, flow_id: FlowID, meta: Option<Meta>) -> Result<()> {
let n = node!(PGMTest, id, flow_id; meta);
FLOW.push(n)
}
pub fn execute_test_str(name: String, flow_id: FlowID, meta: Option<Meta>) -> Result<()> {
let n = node!(PGMTestStr, name, flow_id; meta);
FLOW.push(n)
}
pub fn execute_cz_test(
id: usize,
cz_setup: String,
flow_id: FlowID,
meta: Option<Meta>,
) -> Result<()> {
let n = node!(PGMCz, id, cz_setup, flow_id; meta);
FLOW.push(n)
}
pub fn define_pattern_group(
name: String,
tester: SupportedTester,
kind: Option<PatternGroupType>,
meta: Option<Meta>,
) -> Result<usize> {
let id = crate::STATUS.generate_unique_id();
let n = node!(PGMPatternGroup, id, name, tester, kind; meta);
FLOW.push(n)?;
Ok(id)
}
pub fn push_pattern_to_group(
id: usize,
path: String,
start_label: Option<String>,
meta: Option<Meta>,
) -> Result<()> {
let n = node!(PGMPushPattern, id, path, start_label; meta);
FLOW.push(n)
}
pub fn render(text: String, meta: Option<Meta>) -> Result<()> {
let n = node!(PGMRender, text; meta);
FLOW.push(n)
}
pub fn log(text: String, meta: Option<Meta>) -> Result<()> {
let n = node!(PGMLog, text; meta);
FLOW.push(n)
}
pub fn set_wait_flags(ti_id: usize, flags: Vec<String>, meta: Option<Meta>) -> Result<()> {
let n = node!(PGMIGXLSetWaitFlags, ti_id, flags; meta);
FLOW.push(n)
}
pub fn start_group(
name: String,
tester: Option<SupportedTester>,
kind: GroupType,
flow_id: Option<FlowID>,
meta: Option<Meta>,
) -> Result<usize> {
if kind == GroupType::Flow && flow_id.is_none() {
return error!("A flow_id must be supplied when starting a flow group");
}
let n = node!(PGMGroup, name, tester, kind, flow_id; meta);
FLOW.push_and_open(n)
}
pub fn start_condition(condition: FlowCondition, meta: Option<Meta>) -> Result<usize> {
let n = node!(PGMCondition, condition; meta);
FLOW.push_and_open(n)
}
pub fn define_bin(
number: usize,
is_soft: bool,
kind: BinType,
description: Option<String>,
priority: Option<usize>,
meta: Option<Meta>,
) -> Result<()> {
let n = node!(PGMDefBin, number, is_soft, kind, description, priority; meta);
FLOW.push(n)
}
pub fn bin(hard: usize, soft: Option<usize>, kind: BinType, meta: Option<Meta>) -> Result<()> {
let n = node!(PGMBin, hard, soft, kind; meta);
FLOW.push(n)
}
pub fn start_on_failed(flow_id: FlowID, meta: Option<Meta>) -> Result<usize> {
let n = node!(PGMOnFailed, flow_id; meta);
FLOW.push_and_open(n)
}
pub fn start_on_passed(flow_id: FlowID, meta: Option<Meta>) -> Result<usize> {
let n = node!(PGMOnPassed, flow_id; meta);
FLOW.push_and_open(n)
}