opencode-pilot 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugin/index.js +1 -1
- package/test/unit/paths.test.js +0 -15
- package/service/io.opencode.pilot.plist +0 -29
- package/test/run_tests.bash +0 -34
- package/test/test_actions.bash +0 -248
- package/test/test_cli.bash +0 -157
- package/test/test_helper.bash +0 -140
- package/test/test_plist.bash +0 -124
- package/test/test_poll_service.bash +0 -179
- package/test/test_poller.bash +0 -120
- package/test/test_readiness.bash +0 -313
- package/test/test_repo_config.bash +0 -192
- package/test/test_service.bash +0 -295
package/test/test_readiness.bash
DELETED
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
# Tests for readiness.js - Issue readiness evaluation for self-iteration
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
set -euo pipefail
|
|
7
|
-
|
|
8
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
9
|
-
source "$SCRIPT_DIR/test_helper.bash"
|
|
10
|
-
|
|
11
|
-
SERVICE_DIR="$(dirname "$SCRIPT_DIR")/service"
|
|
12
|
-
|
|
13
|
-
echo "Testing readiness.js module..."
|
|
14
|
-
echo ""
|
|
15
|
-
|
|
16
|
-
# =============================================================================
|
|
17
|
-
# File Structure Tests
|
|
18
|
-
# =============================================================================
|
|
19
|
-
|
|
20
|
-
test_readiness_file_exists() {
|
|
21
|
-
assert_file_exists "$SERVICE_DIR/readiness.js"
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
test_readiness_js_syntax() {
|
|
25
|
-
if ! command -v node &>/dev/null; then
|
|
26
|
-
echo "SKIP: node not available"
|
|
27
|
-
return 0
|
|
28
|
-
fi
|
|
29
|
-
node --check "$SERVICE_DIR/readiness.js" 2>&1 || {
|
|
30
|
-
echo "readiness.js has syntax errors"
|
|
31
|
-
return 1
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
# =============================================================================
|
|
36
|
-
# Export Tests
|
|
37
|
-
# =============================================================================
|
|
38
|
-
|
|
39
|
-
test_readiness_exports_evaluate() {
|
|
40
|
-
grep -q "export.*function evaluateReadiness\|export.*evaluateReadiness" "$SERVICE_DIR/readiness.js" || {
|
|
41
|
-
echo "evaluateReadiness export not found"
|
|
42
|
-
return 1
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
test_readiness_exports_check_labels() {
|
|
47
|
-
grep -q "export.*function checkLabels\|export.*checkLabels" "$SERVICE_DIR/readiness.js" || {
|
|
48
|
-
echo "checkLabels export not found"
|
|
49
|
-
return 1
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
test_readiness_exports_check_dependencies() {
|
|
54
|
-
grep -q "export.*function checkDependencies\|export.*checkDependencies" "$SERVICE_DIR/readiness.js" || {
|
|
55
|
-
echo "checkDependencies export not found"
|
|
56
|
-
return 1
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
test_readiness_exports_calculate_priority() {
|
|
61
|
-
grep -q "export.*function calculatePriority\|export.*calculatePriority" "$SERVICE_DIR/readiness.js" || {
|
|
62
|
-
echo "calculatePriority export not found"
|
|
63
|
-
return 1
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
# =============================================================================
|
|
68
|
-
# Implementation Tests
|
|
69
|
-
# =============================================================================
|
|
70
|
-
|
|
71
|
-
test_readiness_checks_blocking_labels() {
|
|
72
|
-
grep -q "block\|exclude" "$SERVICE_DIR/readiness.js" || {
|
|
73
|
-
echo "Blocking label check not found"
|
|
74
|
-
return 1
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
test_readiness_checks_body_references() {
|
|
79
|
-
grep -q "blocked by\|depends on\|body" "$SERVICE_DIR/readiness.js" || {
|
|
80
|
-
echo "Body reference check not found"
|
|
81
|
-
return 1
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
test_readiness_calculates_priority_score() {
|
|
86
|
-
grep -q "priority\|score\|weight" "$SERVICE_DIR/readiness.js" || {
|
|
87
|
-
echo "Priority calculation not found"
|
|
88
|
-
return 1
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
# =============================================================================
|
|
93
|
-
# Functional Tests
|
|
94
|
-
# =============================================================================
|
|
95
|
-
|
|
96
|
-
test_readiness_blocked_by_label() {
|
|
97
|
-
if ! command -v node &>/dev/null; then
|
|
98
|
-
echo "SKIP: node not available"
|
|
99
|
-
return 0
|
|
100
|
-
fi
|
|
101
|
-
|
|
102
|
-
local result
|
|
103
|
-
result=$(node --experimental-vm-modules -e "
|
|
104
|
-
import { checkLabels } from './service/readiness.js';
|
|
105
|
-
|
|
106
|
-
const issue = {
|
|
107
|
-
labels: [{ name: 'blocked' }, { name: 'bug' }]
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const config = {
|
|
111
|
-
readiness: {
|
|
112
|
-
labels: {
|
|
113
|
-
exclude: ['blocked', 'wontfix']
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const result = checkLabels(issue, config);
|
|
119
|
-
|
|
120
|
-
if (result.ready !== false) {
|
|
121
|
-
console.log('FAIL: Issue with blocked label should not be ready');
|
|
122
|
-
process.exit(1);
|
|
123
|
-
}
|
|
124
|
-
if (!result.reason.includes('blocked')) {
|
|
125
|
-
console.log('FAIL: Reason should mention blocked label');
|
|
126
|
-
process.exit(1);
|
|
127
|
-
}
|
|
128
|
-
console.log('PASS');
|
|
129
|
-
" 2>&1) || {
|
|
130
|
-
echo "Functional test failed: $result"
|
|
131
|
-
return 1
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if ! echo "$result" | grep -q "PASS"; then
|
|
135
|
-
echo "$result"
|
|
136
|
-
return 1
|
|
137
|
-
fi
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
test_readiness_passes_without_blocking_labels() {
|
|
141
|
-
if ! command -v node &>/dev/null; then
|
|
142
|
-
echo "SKIP: node not available"
|
|
143
|
-
return 0
|
|
144
|
-
fi
|
|
145
|
-
|
|
146
|
-
local result
|
|
147
|
-
result=$(node --experimental-vm-modules -e "
|
|
148
|
-
import { checkLabels } from './service/readiness.js';
|
|
149
|
-
|
|
150
|
-
const issue = {
|
|
151
|
-
labels: [{ name: 'enhancement' }, { name: 'good first issue' }]
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const config = {
|
|
155
|
-
readiness: {
|
|
156
|
-
labels: {
|
|
157
|
-
exclude: ['blocked', 'wontfix']
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const result = checkLabels(issue, config);
|
|
163
|
-
|
|
164
|
-
if (result.ready !== true) {
|
|
165
|
-
console.log('FAIL: Issue without blocked labels should be ready');
|
|
166
|
-
process.exit(1);
|
|
167
|
-
}
|
|
168
|
-
console.log('PASS');
|
|
169
|
-
" 2>&1) || {
|
|
170
|
-
echo "Functional test failed: $result"
|
|
171
|
-
return 1
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if ! echo "$result" | grep -q "PASS"; then
|
|
175
|
-
echo "$result"
|
|
176
|
-
return 1
|
|
177
|
-
fi
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
test_readiness_blocked_by_dependency() {
|
|
181
|
-
if ! command -v node &>/dev/null; then
|
|
182
|
-
echo "SKIP: node not available"
|
|
183
|
-
return 0
|
|
184
|
-
fi
|
|
185
|
-
|
|
186
|
-
local result
|
|
187
|
-
result=$(node --experimental-vm-modules -e "
|
|
188
|
-
import { checkDependencies } from './service/readiness.js';
|
|
189
|
-
|
|
190
|
-
const issue = {
|
|
191
|
-
body: 'This feature is blocked by #123 which needs to be done first.'
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
const config = {
|
|
195
|
-
readiness: {
|
|
196
|
-
dependencies: {
|
|
197
|
-
check_body_references: true
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const result = checkDependencies(issue, config);
|
|
203
|
-
|
|
204
|
-
if (result.ready !== false) {
|
|
205
|
-
console.log('FAIL: Issue with dependency reference should not be ready');
|
|
206
|
-
process.exit(1);
|
|
207
|
-
}
|
|
208
|
-
console.log('PASS');
|
|
209
|
-
" 2>&1) || {
|
|
210
|
-
echo "Functional test failed: $result"
|
|
211
|
-
return 1
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if ! echo "$result" | grep -q "PASS"; then
|
|
215
|
-
echo "$result"
|
|
216
|
-
return 1
|
|
217
|
-
fi
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
test_readiness_priority_calculation() {
|
|
221
|
-
if ! command -v node &>/dev/null; then
|
|
222
|
-
echo "SKIP: node not available"
|
|
223
|
-
return 0
|
|
224
|
-
fi
|
|
225
|
-
|
|
226
|
-
local result
|
|
227
|
-
result=$(node --experimental-vm-modules -e "
|
|
228
|
-
import { calculatePriority } from './service/readiness.js';
|
|
229
|
-
|
|
230
|
-
const issue = {
|
|
231
|
-
labels: [{ name: 'critical' }, { name: 'bug' }],
|
|
232
|
-
created_at: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString() // 7 days old
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
const config = {
|
|
236
|
-
readiness: {
|
|
237
|
-
priority: {
|
|
238
|
-
labels: [
|
|
239
|
-
{ label: 'critical', weight: 100 },
|
|
240
|
-
{ label: 'high', weight: 50 }
|
|
241
|
-
],
|
|
242
|
-
age_weight: 1
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
const score = calculatePriority(issue, config);
|
|
248
|
-
|
|
249
|
-
if (score < 100) {
|
|
250
|
-
console.log('FAIL: Critical issue should have score >= 100, got ' + score);
|
|
251
|
-
process.exit(1);
|
|
252
|
-
}
|
|
253
|
-
console.log('PASS');
|
|
254
|
-
" 2>&1) || {
|
|
255
|
-
echo "Functional test failed: $result"
|
|
256
|
-
return 1
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if ! echo "$result" | grep -q "PASS"; then
|
|
260
|
-
echo "$result"
|
|
261
|
-
return 1
|
|
262
|
-
fi
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
# =============================================================================
|
|
266
|
-
# Run Tests
|
|
267
|
-
# =============================================================================
|
|
268
|
-
|
|
269
|
-
echo "File Structure Tests:"
|
|
270
|
-
|
|
271
|
-
for test_func in \
|
|
272
|
-
test_readiness_file_exists \
|
|
273
|
-
test_readiness_js_syntax
|
|
274
|
-
do
|
|
275
|
-
run_test "${test_func#test_}" "$test_func"
|
|
276
|
-
done
|
|
277
|
-
|
|
278
|
-
echo ""
|
|
279
|
-
echo "Export Tests:"
|
|
280
|
-
|
|
281
|
-
for test_func in \
|
|
282
|
-
test_readiness_exports_evaluate \
|
|
283
|
-
test_readiness_exports_check_labels \
|
|
284
|
-
test_readiness_exports_check_dependencies \
|
|
285
|
-
test_readiness_exports_calculate_priority
|
|
286
|
-
do
|
|
287
|
-
run_test "${test_func#test_}" "$test_func"
|
|
288
|
-
done
|
|
289
|
-
|
|
290
|
-
echo ""
|
|
291
|
-
echo "Implementation Tests:"
|
|
292
|
-
|
|
293
|
-
for test_func in \
|
|
294
|
-
test_readiness_checks_blocking_labels \
|
|
295
|
-
test_readiness_checks_body_references \
|
|
296
|
-
test_readiness_calculates_priority_score
|
|
297
|
-
do
|
|
298
|
-
run_test "${test_func#test_}" "$test_func"
|
|
299
|
-
done
|
|
300
|
-
|
|
301
|
-
echo ""
|
|
302
|
-
echo "Functional Tests:"
|
|
303
|
-
|
|
304
|
-
for test_func in \
|
|
305
|
-
test_readiness_blocked_by_label \
|
|
306
|
-
test_readiness_passes_without_blocking_labels \
|
|
307
|
-
test_readiness_blocked_by_dependency \
|
|
308
|
-
test_readiness_priority_calculation
|
|
309
|
-
do
|
|
310
|
-
run_test "${test_func#test_}" "$test_func"
|
|
311
|
-
done
|
|
312
|
-
|
|
313
|
-
print_summary
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
# Tests for repo-config.js - Unified repository configuration
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
set -euo pipefail
|
|
7
|
-
|
|
8
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
9
|
-
source "$SCRIPT_DIR/test_helper.bash"
|
|
10
|
-
|
|
11
|
-
SERVICE_DIR="$(dirname "$SCRIPT_DIR")/service"
|
|
12
|
-
|
|
13
|
-
echo "Testing repo-config.js module..."
|
|
14
|
-
echo ""
|
|
15
|
-
|
|
16
|
-
# =============================================================================
|
|
17
|
-
# File Structure Tests
|
|
18
|
-
# =============================================================================
|
|
19
|
-
|
|
20
|
-
test_repo_config_file_exists() {
|
|
21
|
-
assert_file_exists "$SERVICE_DIR/repo-config.js"
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
test_repo_config_js_syntax() {
|
|
25
|
-
if ! command -v node &>/dev/null; then
|
|
26
|
-
echo "SKIP: node not available"
|
|
27
|
-
return 0
|
|
28
|
-
fi
|
|
29
|
-
node --check "$SERVICE_DIR/repo-config.js" 2>&1 || {
|
|
30
|
-
echo "repo-config.js has syntax errors"
|
|
31
|
-
return 1
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
# =============================================================================
|
|
36
|
-
# Export Tests
|
|
37
|
-
# =============================================================================
|
|
38
|
-
|
|
39
|
-
test_repo_config_exports_load_config() {
|
|
40
|
-
grep -q "export.*function loadRepoConfig\|export.*loadRepoConfig" "$SERVICE_DIR/repo-config.js" || {
|
|
41
|
-
echo "loadRepoConfig export not found"
|
|
42
|
-
return 1
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
test_repo_config_exports_get_config() {
|
|
47
|
-
grep -q "export.*function getRepoConfig\|export.*getRepoConfig" "$SERVICE_DIR/repo-config.js" || {
|
|
48
|
-
echo "getRepoConfig export not found"
|
|
49
|
-
return 1
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
test_repo_config_exports_get_all_sources() {
|
|
54
|
-
grep -q "export.*function getAllSources\|export.*getAllSources" "$SERVICE_DIR/repo-config.js" || {
|
|
55
|
-
echo "getAllSources export not found"
|
|
56
|
-
return 1
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
# =============================================================================
|
|
61
|
-
# Implementation Tests
|
|
62
|
-
# =============================================================================
|
|
63
|
-
|
|
64
|
-
test_repo_config_supports_yaml() {
|
|
65
|
-
grep -q "yaml\|YAML" "$SERVICE_DIR/repo-config.js" || {
|
|
66
|
-
echo "YAML support not found"
|
|
67
|
-
return 1
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
test_repo_config_supports_source_config() {
|
|
72
|
-
grep -q "sources" "$SERVICE_DIR/repo-config.js" || {
|
|
73
|
-
echo "Sources support not found"
|
|
74
|
-
return 1
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
test_repo_config_supports_tool_mappings() {
|
|
79
|
-
grep -q "mappings\|tools" "$SERVICE_DIR/repo-config.js" || {
|
|
80
|
-
echo "Tool mappings support not found"
|
|
81
|
-
return 1
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
# =============================================================================
|
|
86
|
-
# Functional Tests
|
|
87
|
-
# =============================================================================
|
|
88
|
-
|
|
89
|
-
test_repo_config_returns_empty_for_unknown_repo() {
|
|
90
|
-
if ! command -v node &>/dev/null; then
|
|
91
|
-
echo "SKIP: node not available"
|
|
92
|
-
return 0
|
|
93
|
-
fi
|
|
94
|
-
|
|
95
|
-
local result
|
|
96
|
-
result=$(node --experimental-vm-modules -e "
|
|
97
|
-
import { getRepoConfig } from './service/repo-config.js';
|
|
98
|
-
|
|
99
|
-
// Get config for non-existent repo should return empty object
|
|
100
|
-
const config = getRepoConfig('nonexistent/repo');
|
|
101
|
-
|
|
102
|
-
if (typeof config !== 'object') {
|
|
103
|
-
console.log('FAIL: Expected object for unknown repo');
|
|
104
|
-
process.exit(1);
|
|
105
|
-
}
|
|
106
|
-
console.log('PASS');
|
|
107
|
-
" 2>&1) || {
|
|
108
|
-
echo "Functional test failed: $result"
|
|
109
|
-
return 1
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if ! echo "$result" | grep -q "PASS"; then
|
|
113
|
-
echo "$result"
|
|
114
|
-
return 1
|
|
115
|
-
fi
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
test_repo_config_gets_sources() {
|
|
119
|
-
if ! command -v node &>/dev/null; then
|
|
120
|
-
echo "SKIP: node not available"
|
|
121
|
-
return 0
|
|
122
|
-
fi
|
|
123
|
-
|
|
124
|
-
local result
|
|
125
|
-
result=$(node --experimental-vm-modules -e "
|
|
126
|
-
import { getAllSources } from './service/repo-config.js';
|
|
127
|
-
|
|
128
|
-
// getAllSources should return an array
|
|
129
|
-
const sources = getAllSources();
|
|
130
|
-
|
|
131
|
-
if (!Array.isArray(sources)) {
|
|
132
|
-
console.log('FAIL: Expected array from getAllSources');
|
|
133
|
-
process.exit(1);
|
|
134
|
-
}
|
|
135
|
-
console.log('PASS');
|
|
136
|
-
" 2>&1) || {
|
|
137
|
-
echo "Functional test failed: $result"
|
|
138
|
-
return 1
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if ! echo "$result" | grep -q "PASS"; then
|
|
142
|
-
echo "$result"
|
|
143
|
-
return 1
|
|
144
|
-
fi
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
# =============================================================================
|
|
148
|
-
# Run Tests
|
|
149
|
-
# =============================================================================
|
|
150
|
-
|
|
151
|
-
echo "File Structure Tests:"
|
|
152
|
-
|
|
153
|
-
for test_func in \
|
|
154
|
-
test_repo_config_file_exists \
|
|
155
|
-
test_repo_config_js_syntax
|
|
156
|
-
do
|
|
157
|
-
run_test "${test_func#test_}" "$test_func"
|
|
158
|
-
done
|
|
159
|
-
|
|
160
|
-
echo ""
|
|
161
|
-
echo "Export Tests:"
|
|
162
|
-
|
|
163
|
-
for test_func in \
|
|
164
|
-
test_repo_config_exports_load_config \
|
|
165
|
-
test_repo_config_exports_get_config \
|
|
166
|
-
test_repo_config_exports_get_all_sources
|
|
167
|
-
do
|
|
168
|
-
run_test "${test_func#test_}" "$test_func"
|
|
169
|
-
done
|
|
170
|
-
|
|
171
|
-
echo ""
|
|
172
|
-
echo "Implementation Tests:"
|
|
173
|
-
|
|
174
|
-
for test_func in \
|
|
175
|
-
test_repo_config_supports_yaml \
|
|
176
|
-
test_repo_config_supports_source_config \
|
|
177
|
-
test_repo_config_supports_tool_mappings
|
|
178
|
-
do
|
|
179
|
-
run_test "${test_func#test_}" "$test_func"
|
|
180
|
-
done
|
|
181
|
-
|
|
182
|
-
echo ""
|
|
183
|
-
echo "Functional Tests:"
|
|
184
|
-
|
|
185
|
-
for test_func in \
|
|
186
|
-
test_repo_config_returns_empty_for_unknown_repo \
|
|
187
|
-
test_repo_config_gets_sources
|
|
188
|
-
do
|
|
189
|
-
run_test "${test_func#test_}" "$test_func"
|
|
190
|
-
done
|
|
191
|
-
|
|
192
|
-
print_summary
|