-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-all-tests.sh
More file actions
executable file
·1238 lines (1163 loc) · 53.4 KB
/
run-all-tests.sh
File metadata and controls
executable file
·1238 lines (1163 loc) · 53.4 KB
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Comprehensive test runner for all NAAb tests
set -e
NAAB_BIN="./build/naab-lang"
# V-SC-009: Back up and clear trust store so unsigned test govern.json files work
REAL_TRUST="$HOME/.naab/trusted-keys"
TRUST_BAK=""
if [ -d "$REAL_TRUST" ]; then
TRUST_BAK=$(mktemp -d "${TMPDIR:-/tmp}/trust_bak_run_XXXXXX")
mv "$REAL_TRUST" "$TRUST_BAK/trusted-keys"
fi
restore_trust_store() {
rm -rf "$REAL_TRUST"
if [ -n "$TRUST_BAK" ] && [ -d "$TRUST_BAK/trusted-keys" ]; then
mv "$TRUST_BAK/trusted-keys" "$REAL_TRUST"
rm -rf "$TRUST_BAK"
fi
}
trap 'restore_trust_store' EXIT
TEST_DIRS=(
"examples"
"tests/bugs"
"tests/comprehensive"
"tests/integration"
"tests/security"
"tests/benchmarks"
"tests/debugger"
"tests/error_messages"
"tests/fixtures"
"tests/formatter"
"tests/llm_patterns"
"tests/path_resolution"
"tests/chapter verification"
"tests/governance_v3"
"tests/governance_v4"
"tests/robustness"
"tests/governance_plugins"
"tests/package_manager"
"tests/persistent"
"tests/type_system/valid"
"tests/stdlib"
"tests"
)
PASSED=0
FAILED=0
ERROR_BEHAVIOR=0
MISSING_EXECUTOR=0
NEEDS_TREE_WALK=0
SKIPPED=0
TOTAL=0
declare -a FAILED_TESTS
declare -a PASSED_TESTS
# Category 1: Tests DESIGNED to exit non-zero (error behavior verification)
declare -A EXPECTED_ERROR_TESTS
# Parser/runtime error message tests
EXPECTED_ERROR_TESTS["test_block_error.naab"]=1
EXPECTED_ERROR_TESTS["test_class_error.naab"]=1
EXPECTED_ERROR_TESTS["test_var_error.naab"]=1
EXPECTED_ERROR_TESTS["test_var_toplevel_error.naab"]=1
EXPECTED_ERROR_TESTS["test_func_main_error.naab"]=1
EXPECTED_ERROR_TESTS["test_reserved_keyword_error.naab"]=1
EXPECTED_ERROR_TESTS["test_sys_hint.naab"]=1
EXPECTED_ERROR_TESTS["test_variable_binding_error.naab"]=1
EXPECTED_ERROR_TESTS["parser_errors_test.naab"]=1
# Gorilla test #4 helper error tests (try-expr now valid since 3809f25d)
EXPECTED_ERROR_TESTS["test_throw_expression_error.naab"]=1
EXPECTED_ERROR_TESTS["test_throw_match_error.naab"]=1
EXPECTED_ERROR_TESTS["test_string_match_error.naab"]=1
EXPECTED_ERROR_TESTS["test_js_variable_binding_error.naab"]=1
EXPECTED_ERROR_TESTS["test_unclosed_block.naab"]=1
# Governance v3/v4 tests designed to be blocked by governance
EXPECTED_ERROR_TESTS["test_degraded.naab"]=1
EXPECTED_ERROR_TESTS["test_complexity_floor.naab"]=1
EXPECTED_ERROR_TESTS["test_complexity_names_fail.naab"]=1
EXPECTED_ERROR_TESTS["test_complexity_names_pass.naab"]=1
EXPECTED_ERROR_TESTS["test_contracts_empty.naab"]=1
EXPECTED_ERROR_TESTS["test_contracts_non_empty_null.naab"]=1
EXPECTED_ERROR_TESTS["test_contracts_null_return.naab"]=1
EXPECTED_ERROR_TESTS["test_contracts_range_violation.naab"]=1
EXPECTED_ERROR_TESTS["test_contracts_return_keys.naab"]=1
EXPECTED_ERROR_TESTS["test_contracts_type_mismatch.naab"]=1
EXPECTED_ERROR_TESTS["test_contracts_violation.naab"]=1
EXPECTED_ERROR_TESTS["test_evasion_advisory_elevation.naab"]=1
EXPECTED_ERROR_TESTS["polyglot_enforcement_test.naab"]=1
EXPECTED_ERROR_TESTS["test_evasion_js_comment.naab"]=1
EXPECTED_ERROR_TESTS["test_evasion_naab_stub.naab"]=1
EXPECTED_ERROR_TESTS["test_evasion_private_stub.naab"]=1
EXPECTED_ERROR_TESTS["test_evasion_triple_quote.naab"]=1
EXPECTED_ERROR_TESTS["test_v3_banned_function.naab"]=1
EXPECTED_ERROR_TESTS["test_v3_blocked_import.naab"]=1
EXPECTED_ERROR_TESTS["test_v3_custom_rule.naab"]=1
EXPECTED_ERROR_TESTS["test_v3_hallucinated_api.naab"]=1
EXPECTED_ERROR_TESTS["test_v3_incomplete_logic.naab"]=1
EXPECTED_ERROR_TESTS["test_v3_oversimplification.naab"]=1
EXPECTED_ERROR_TESTS["test_v3_privilege_escalation.naab"]=1
EXPECTED_ERROR_TESTS["test_v3_secret_detection.naab"]=1
EXPECTED_ERROR_TESTS["test_v3_simulation_markers.naab"]=1
EXPECTED_ERROR_TESTS["test_v3_sql_injection.naab"]=1
EXPECTED_ERROR_TESTS["test_v3_unsafe_deser.naab"]=1
# Governance plugin tests designed to be blocked
EXPECTED_ERROR_TESTS["test_plugin_block.naab"]=1
# Nim executor works but test uses assert() which is not a stdlib function (test bug)
EXPECTED_ERROR_TESTS["nim_test.naab"]=1
# Example files with language/executor bugs (not missing compilers)
EXPECTED_ERROR_TESTS["anti_patterns.naab"]=1 # single-line polyglot blocks not supported
EXPECTED_ERROR_TESTS["polyglot_showcase.naab"]=1 # array.len not a function (use len())
EXPECTED_ERROR_TESTS["before_after_optimization.naab"]=1 # Julia executor failure on Termux
EXPECTED_ERROR_TESTS["test_instruction_following.naab"]=1 # secret detection now catches AKIA key in NAAb string (BUG-2 fix)
# Category 2: Tests that need compilers/executors not installed on this platform
# NOTE: Termux has g++, nim, node, go, rustc, julia, csc/mono, ruby, php, python3.
# CI runners may not have all of these, so tests that need multiple polyglot
# executors should stay here even if they pass on Termux.
declare -A MISSING_EXECUTOR_TESTS
MISSING_EXECUTOR_TESTS["polyglot_optimization_test.naab"]=1 # needs numpy, Go, Nim, Ruby
# Category 2b: Tests that use 'use BLOCK-...' syntax requiring --tree-walk mode.
# VM mode rejects this syntax with "Compiler error: 'use BLOCK-...' block-loading
# syntax is not supported in VM mode." This is a NAAb engine limitation, not a
# missing compiler.
declare -A NEEDS_TREE_WALK_TESTS
NEEDS_TREE_WALK_TESTS["test_all_languages_full.naab"]=1 # uses BLOCK-JS-FORMAT etc.
NEEDS_TREE_WALK_TESTS["test_cross_lang_extended.naab"]=1 # uses BLOCK-CPP-MATH etc.
NEEDS_TREE_WALK_TESTS["test_cross_lang_simple.naab"]=1 # uses BLOCK-CPP-MATH
NEEDS_TREE_WALK_TESTS["TUTORIAL_POLYGLOT_BLOCKS.naab"]=1 # uses BLOCK-CPP-*, BLOCK-CS-*, etc.
NEEDS_TREE_WALK_TESTS["MONO_EXHAUSTIVE_TEST.naab"]=1 # uses BLOCK-* (needs blocks/library/)
NEEDS_TREE_WALK_TESTS["test_llvm_block.naab"]=1 # uses BLOCK-CPP-23886
# examples/ that use BLOCK-... syntax
NEEDS_TREE_WALK_TESTS["api_server.naab"]=1 # uses BLOCK-CPP-VALIDATOR, BLOCK-JS-TEMPLATE
NEEDS_TREE_WALK_TESTS["cpp_math.naab"]=1 # uses BLOCK-CPP-MATH
NEEDS_TREE_WALK_TESTS["data_pipeline.naab"]=1 # uses BLOCK-CPP-MATH, BLOCK-JS-CHART
NEEDS_TREE_WALK_TESTS["multi_language_analytics.naab"]=1 # uses BLOCK-PY-*, BLOCK-CPP-*, BLOCK-JS-*
NEEDS_TREE_WALK_TESTS["web_scraper.naab"]=1 # uses BLOCK-JS-FORMAT
# Category 3: Files that are NOT standalone tests (should not be run directly)
declare -A SKIP_FILES
SKIP_FILES["edge_helper_module.naab"]=1 # imported by edge tests, not standalone
SKIP_FILES["chaos_module_taint.naab"]=1 # imported by chaos tests, not standalone
SKIP_FILES["test_lexer_polyglot.naab"]=1 # file does not exist (stale reference)
SKIP_FILES["test_polyglot_types.naab"]=1 # file does not exist (stale reference)
SKIP_FILES["test_plugin.naab"]=1 # governance plugin library, not standalone
# Directories to skip entirely
SKIP_DIRS=(
"tests/chapter verification/ch0_full_projects" # Gemini-generated projects (most have runtime issues)
"tests/property" # Property-based tests run via dedicated runner, not standalone
)
echo "═══════════════════════════════════════════════════════════"
echo " NAAb Language - Comprehensive Test Suite Runner"
echo "═══════════════════════════════════════════════════════════"
echo ""
# Check if naab-lang exists
if [ ! -f "$NAAB_BIN" ]; then
echo "Error: naab-lang binary not found at $NAAB_BIN"
echo "Run 'cd build && make naab-lang' first"
exit 1
fi
# Function to check if a path should be skipped
should_skip() {
local file_path="$1"
for skip_dir in "${SKIP_DIRS[@]}"; do
if [[ "$file_path" == *"$skip_dir"* ]]; then
return 0
fi
done
return 1
}
# Function to run a single test
run_test() {
local test_file="$1"
local test_name=$(basename "$test_file")
local timeout_duration="${2:-10s}"
# Skip files in excluded directories
if should_skip "$test_file"; then
SKIPPED=$((SKIPPED + 1))
return
fi
# Skip non-standalone files
if [ "${SKIP_FILES[$test_name]}" = "1" ]; then
SKIPPED=$((SKIPPED + 1))
return
fi
# Skip files inside naab_modules/ (package libraries, not standalone tests)
if [[ "$test_file" == *"/naab_modules/"* ]]; then
SKIPPED=$((SKIPPED + 1))
return
fi
TOTAL=$((TOTAL + 1))
# Governance tests need governance enabled; all others disable it for speed
local gov_flag="--no-governance"
if [[ "$test_file" == *"/governance_v3/"* ]] || [[ "$test_file" == *"/governance_v4/"* ]] || [[ "$test_file" == *"/robustness/"* ]] || [[ "$test_file" == *"/governance_plugins/"* ]]; then
gov_flag=""
fi
# Special case: soft_override and edge tests need --governance-override flag
if [[ "$test_file" == *"/soft_override/"* ]] || [[ "$test_file" == *"/edge/"* ]]; then
gov_flag="--governance-override"
fi
# Security sandbox tests need the right sandbox level to actually enforce blocking
# Only inject for tests with "sandbox" in the name — other security tests (e.g., overflow) run normally
local sandbox_flag=""
if [[ "$test_file" == *"/security/"* ]] && [[ "$test_name" == *"sandbox"* ]]; then
if [[ "$test_name" == *"http"* ]]; then
sandbox_flag="--sandbox-level standard"
else
sandbox_flag="--sandbox-level restricted"
fi
fi
# Run the test with timeout
local output_file="$HOME/.naab_test_output_$$.txt"
if timeout "$timeout_duration" "$NAAB_BIN" $gov_flag $sandbox_flag run "$test_file" > "$output_file" 2>&1; then
PASSED=$((PASSED + 1))
PASSED_TESTS+=("$test_name")
echo " PASS: $test_name"
else
local exit_code=$?
# Check which category this failure belongs to
if [ "${EXPECTED_ERROR_TESTS[$test_name]}" = "1" ]; then
ERROR_BEHAVIOR=$((ERROR_BEHAVIOR + 1))
echo " XFAIL: $test_name (error behavior test)"
elif [ "${MISSING_EXECUTOR_TESTS[$test_name]}" = "1" ]; then
MISSING_EXECUTOR=$((MISSING_EXECUTOR + 1))
echo " XFAIL: $test_name (missing executor)"
elif [ "${NEEDS_TREE_WALK_TESTS[$test_name]}" = "1" ]; then
NEEDS_TREE_WALK=$((NEEDS_TREE_WALK + 1))
echo " XFAIL: $test_name (needs --tree-walk)"
elif [ -f "$output_file" ] && grep -q "Python support not available" "$output_file"; then
MISSING_EXECUTOR=$((MISSING_EXECUTOR + 1))
echo " XFAIL: $test_name (missing executor)"
elif [ $exit_code -eq 124 ]; then
echo " TIMEOUT: $test_name (>$timeout_duration)"
FAILED=$((FAILED + 1))
FAILED_TESTS+=("$test_name (timeout >$timeout_duration)")
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("$test_name")
echo " FAIL: $test_name"
# Show first line of error
if [ -f "$output_file" ]; then
head -1 "$output_file" | sed 's/^/ /'
fi
fi
fi
rm -f "$output_file"
}
# Run tests from each directory
for dir in "${TEST_DIRS[@]}"; do
if [ ! -d "$dir" ]; then
continue
fi
echo ""
echo "-----------------------------------------------------------"
echo " Testing: $dir"
echo "-----------------------------------------------------------"
# Set timeout based on directory
timeout="10s"
if [ "$dir" = "tests/comprehensive" ]; then
timeout="180s"
elif [ "$dir" = "tests/chapter_verification" ]; then
timeout="30s"
elif [ "$dir" = "examples" ]; then
timeout="30s"
elif [ "$dir" = "tests/integration" ]; then
timeout="30s"
elif [ "$dir" = "tests/security" ]; then
timeout="120s"
elif [ "$dir" = "tests/benchmarks" ]; then
timeout="60s"
elif [ "$dir" = "tests/governance_v3" ] || [ "$dir" = "tests/governance_v4" ]; then
timeout="60s" # Governance tests run polyglot blocks
elif [ "$dir" = "tests/stdlib" ]; then
timeout="30s"
fi
# Find all .naab files
if [ "$dir" = "tests" ]; then
# For tests/ root, only get direct .naab files, not subdirs
while IFS= read -r -d '' test_file; do
run_test "$test_file" "$timeout"
done < <(find "$dir" -maxdepth 1 -name "*.naab" -type f -print0 | sort -z)
elif [ "$dir" = "examples" ]; then
# Exclude agent-governance (requires run.sh setup with test data)
while IFS= read -r -d '' test_file; do
run_test "$test_file" "$timeout"
done < <(find "$dir" -name "*.naab" -type f -not -path "*/agent-governance/*" -print0 | sort -z)
else
while IFS= read -r -d '' test_file; do
run_test "$test_file" "$timeout"
done < <(find "$dir" -name "*.naab" -type f -print0 | sort -z)
fi
done
# Type system error detection tests (run with --strict-types)
echo ""
echo "-----------------------------------------------------------"
echo " Testing: tests/type_system/errors (--strict-types)"
echo "-----------------------------------------------------------"
for f in tests/type_system/errors/*.naab; do
[ -f "$f" ] || continue
test_name=$(basename "$f")
TOTAL=$((TOTAL + 1))
output_file="$HOME/.naab_test_output_$$.txt"
if timeout 10s "$NAAB_BIN" --strict-types run "$f" > "$output_file" 2>&1; then
FAILED=$((FAILED + 1))
FAILED_TESTS+=("$test_name (should have type errors but passed)")
echo " FAIL: $test_name — should have type errors but passed"
else
ERROR_BEHAVIOR=$((ERROR_BEHAVIOR + 1))
echo " XFAIL: $test_name (type error caught)"
fi
rm -f "$output_file"
done
# Also verify valid code passes --strict-types
echo ""
echo "-----------------------------------------------------------"
echo " Testing: tests/type_system/valid (--strict-types)"
echo "-----------------------------------------------------------"
for f in tests/type_system/valid/*.naab; do
[ -f "$f" ] || continue
test_name=$(basename "$f")
TOTAL=$((TOTAL + 1))
output_file="$HOME/.naab_test_output_$$.txt"
if timeout 10s "$NAAB_BIN" --strict-types run "$f" > "$output_file" 2>&1; then
PASSED=$((PASSED + 1))
PASSED_TESTS+=("$test_name")
echo " PASS: $test_name --strict-types"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("$test_name --strict-types (false positive)")
echo " FAIL: $test_name --strict-types — false positive"
if [ -f "$output_file" ]; then
head -1 "$output_file" | sed 's/^/ /'
fi
fi
rm -f "$output_file"
done
# --- Property-Based Tests ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Property-Based Invariant Tests"
echo "═══════════════════════════════════════════════════════════"
echo ""
PROPERTY_SCRIPT="tests/property/run_property_tests.sh"
if [ -f "$PROPERTY_SCRIPT" ]; then
if bash "$PROPERTY_SCRIPT" 2>&1; then
echo ""
echo " Property tests: ALL INVARIANTS HOLD"
else
echo ""
echo " Property tests: INVARIANT(S) VIOLATED"
FAILED=$((FAILED + 1))
FAILED_TESTS+=("property-based invariants")
fi
else
echo " Property test script not found, skipping"
fi
# --- LSP Integration Tests ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " LSP Integration Tests"
echo "═══════════════════════════════════════════════════════════"
echo ""
LSP_SCRIPT="tests/lsp/test_lsp_basic.sh"
if [ -f "$LSP_SCRIPT" ] && [ -x "build/naab-lsp" ]; then
if bash "$LSP_SCRIPT" 2>&1; then
echo ""
echo " LSP tests: ALL PASSED"
else
echo ""
echo " LSP tests: FAILURE(S)"
FAILED=$((FAILED + 1))
FAILED_TESTS+=("lsp-integration")
fi
else
echo " LSP test script or naab-lsp binary not found, skipping"
fi
# --- Bytecode VM Tests ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Bytecode VM Tests (--vm)"
echo "═══════════════════════════════════════════════════════════"
echo ""
VM_TEST_DIR="tests/vm"
VM_PASSED=0
VM_FAILED=0
VM_TOTAL=0
if [ -d "$VM_TEST_DIR" ]; then
for f in "$VM_TEST_DIR"/*.naab; do
[ -f "$f" ] || continue
test_name=$(basename "$f")
VM_TOTAL=$((VM_TOTAL + 1))
TOTAL=$((TOTAL + 1))
output_file="$HOME/.naab_test_output_$$.txt"
if timeout 10s "$NAAB_BIN" --vm "$f" > "$output_file" 2>&1; then
VM_PASSED=$((VM_PASSED + 1))
PASSED=$((PASSED + 1))
PASSED_TESTS+=("$test_name (--vm)")
echo " PASS: $test_name (--vm)"
else
VM_FAILED=$((VM_FAILED + 1))
FAILED=$((FAILED + 1))
FAILED_TESTS+=("$test_name (--vm)")
echo " FAIL: $test_name (--vm)"
if [ -f "$output_file" ]; then
head -1 "$output_file" | sed 's/^/ /'
fi
fi
rm -f "$output_file"
done
echo ""
echo " VM tests: $VM_PASSED/$VM_TOTAL passed"
else
echo " No VM test directory (tests/vm/), skipping"
fi
# --- Report Format Tests ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Report Format Tests (SARIF/JUnit/JSON)"
echo "═══════════════════════════════════════════════════════════"
echo ""
REPORT_SCRIPT="tests/cli/test_report_formats.sh"
if [ -f "$REPORT_SCRIPT" ]; then
if bash "$REPORT_SCRIPT" 2>&1; then
echo ""
echo " Report format tests: ALL PASSED"
else
echo ""
echo " Report format tests: FAILURE(S)"
FAILED=$((FAILED + 1))
FAILED_TESTS+=("report-format-tests")
fi
else
echo " Report format test script not found, skipping"
fi
# --- CLI Init Governance Tests ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " CLI Init Governance Tests"
echo "═══════════════════════════════════════════════════════════"
echo ""
INIT_SCRIPT="tests/cli/test_init_governance.sh"
if [ -f "$INIT_SCRIPT" ]; then
if bash "$INIT_SCRIPT" 2>&1; then
echo ""
echo " Init governance tests: ALL PASSED"
else
echo ""
echo " Init governance tests: FAILURE(S)"
FAILED=$((FAILED + 1))
FAILED_TESTS+=("init-governance")
fi
else
echo " Init governance test script not found, skipping"
fi
# --- Multi-Agent Governance Integration Tests ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Multi-Agent Governance Integration Tests"
echo "═══════════════════════════════════════════════════════════"
echo ""
MULTIAGENT_SCRIPT="tests/cli/test_multiagent_governance.sh"
if [ -f "$MULTIAGENT_SCRIPT" ]; then
if bash "$MULTIAGENT_SCRIPT" 2>&1; then
echo ""
echo " Multi-agent governance tests: ALL PASSED"
else
echo ""
echo " Multi-agent governance tests: FAILURE(S)"
FAILED=$((FAILED + 1))
FAILED_TESTS+=("multiagent-governance")
fi
else
echo " Multi-agent governance test script not found, skipping"
fi
# --- CLI Flag Tests ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " CLI Flag Tests"
echo "═══════════════════════════════════════════════════════════"
echo ""
CLI_FLAGS_SCRIPT="tests/cli/test_cli_flags.sh"
if [ -f "$CLI_FLAGS_SCRIPT" ]; then
if bash "$CLI_FLAGS_SCRIPT" 2>&1; then
echo ""
echo " CLI flag tests: ALL PASSED"
else
echo ""
echo " CLI flag tests: FAILURE(S)"
FAILED=$((FAILED + 1))
FAILED_TESTS+=("cli-flag-tests")
fi
else
echo " CLI flag test script not found, skipping"
fi
# --- GC Flag Tests ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " GC Flag Tests (--gc-threshold, --gc-stats)"
echo "═══════════════════════════════════════════════════════════"
echo ""
GC_FLAGS_SCRIPT="tests/cli/test_gc_flags.sh"
if [ -f "$GC_FLAGS_SCRIPT" ]; then
if bash "$GC_FLAGS_SCRIPT" 2>&1; then
echo ""
echo " GC flag tests: ALL PASSED"
else
echo ""
echo " GC flag tests: FAILURE(S)"
FAILED=$((FAILED + 1))
FAILED_TESTS+=("gc-flag-tests")
fi
else
echo " GC flag test script not found, skipping"
fi
# --- Sandbox Security Tests ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Sandbox Security Tests"
echo "═══════════════════════════════════════════════════════════"
echo ""
for sec_script in \
"tests/security/test_sandbox_file_restricted.sh" \
"tests/security/test_sandbox_http_restricted.sh" \
"tests/security/test_sandbox_env_restricted.sh" \
"tests/security/test_sandbox_symlink.sh" \
"tests/security/test_sandbox_exit_codes.sh"; do
if [ -f "$sec_script" ]; then
script_name=$(basename "$sec_script")
if bash "$sec_script" 2>&1; then
echo ""
echo " $script_name: ALL PASSED"
else
echo ""
echo " $script_name: FAILURE(S)"
FAILED=$((FAILED + 1))
FAILED_TESTS+=("$script_name")
fi
else
echo " $(basename "$sec_script"): not found, skipping"
fi
done
# --- naab-gov CLI Tests (Phase 8.2) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " naab-gov Governance CLI Tests"
echo "═══════════════════════════════════════════════════════════"
echo ""
# --- Governance Enforcement Tests ---
GOV_ENFORCE_SCRIPT="tests/governance/test_governance_enforcement.sh"
if [ -f "$GOV_ENFORCE_SCRIPT" ]; then
if bash "$GOV_ENFORCE_SCRIPT" "$NAAB_BIN" 2>&1; then
echo " test_governance_enforcement.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_governance_enforcement.sh")
fi
else
echo " test_governance_enforcement.sh: not found, skipping"
fi
GOV_SCRIPT="tests/cli/test_naab_gov.sh"
if [ -f "$GOV_SCRIPT" ]; then
if bash "$GOV_SCRIPT" 2>&1; then
echo " test_naab_gov.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_naab_gov.sh")
fi
else
echo " test_naab_gov.sh: not found, skipping"
fi
# --- libnaab Embedding Tests (Phase 8.1) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " libnaab Embedding Build Tests"
echo "═══════════════════════════════════════════════════════════"
echo ""
EMBED_SCRIPT="tests/embedding/test_libnaab_build.sh"
if [ -f "$EMBED_SCRIPT" ]; then
if bash "$EMBED_SCRIPT" 2>&1; then
echo " test_libnaab_build.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_libnaab_build.sh")
fi
else
echo " test_libnaab_build.sh: not found, skipping"
fi
# --- LSP New Method Tests (Phase 8.3) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " LSP New Method Tests (codeAction/workspaceSymbol/rename)"
echo "═══════════════════════════════════════════════════════════"
echo ""
LSP_NEW_SCRIPT="tests/lsp/test_lsp_new_methods.sh"
if [ -f "$LSP_NEW_SCRIPT" ] && [ -f "build/naab-lsp" ]; then
if bash "$LSP_NEW_SCRIPT" 2>&1; then
echo " test_lsp_new_methods.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_lsp_new_methods.sh")
fi
else
echo " test_lsp_new_methods.sh: skipped (naab-lsp not built or script not found)"
fi
# --- Deterministic Build / Lockfile Tests (Phase 8.4) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Deterministic Build Lockfile Tests"
echo "═══════════════════════════════════════════════════════════"
echo ""
LOCK_SCRIPT="tests/deterministic/test_lockfile.sh"
if [ -f "$LOCK_SCRIPT" ]; then
if bash "$LOCK_SCRIPT" 2>&1; then
echo " test_lockfile.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_lockfile.sh")
fi
else
echo " test_lockfile.sh: not found, skipping"
fi
# --- Platform Abstraction Tests (Phase 7.3) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Platform Abstraction Tests"
echo "═══════════════════════════════════════════════════════════"
echo ""
PLATFORM_SCRIPT="tests/platform/test_platform_posix.sh"
if [ -f "$PLATFORM_SCRIPT" ]; then
if bash "$PLATFORM_SCRIPT" 2>&1; then
echo " test_platform_posix.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_platform_posix.sh")
fi
else
echo " test_platform_posix.sh: not found, skipping"
fi
# --- Governance Exit Code Tests (Sprint 9) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Governance Exit Code Tests (exit 2/3)"
echo "═══════════════════════════════════════════════════════════"
echo ""
GOV_EXIT_SCRIPT="tests/cli/test_governance_exit_codes.sh"
if [ -f "$GOV_EXIT_SCRIPT" ]; then
if bash "$GOV_EXIT_SCRIPT" 2>&1; then
echo " test_governance_exit_codes.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_governance_exit_codes.sh")
fi
else
echo " test_governance_exit_codes.sh: not found, skipping"
fi
# --- Pipe Mode Tests (Sprint 9) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Pipe Mode Tests (--pipe flag)"
echo "═══════════════════════════════════════════════════════════"
echo ""
PIPE_SCRIPT="tests/cli/test_pipe_mode.sh"
if [ -f "$PIPE_SCRIPT" ]; then
if bash "$PIPE_SCRIPT" 2>&1; then
echo " test_pipe_mode.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_pipe_mode.sh")
fi
else
echo " test_pipe_mode.sh: not found, skipping"
fi
# --- VM UseStatement Error Tests (Finding G) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " VM UseStatement Error Tests (clear error, not crash)"
echo "═══════════════════════════════════════════════════════════"
echo ""
USESTMT_SCRIPT="tests/vm/test_use_statement_error.sh"
if [ -f "$USESTMT_SCRIPT" ]; then
if bash "$USESTMT_SCRIPT" 2>&1; then
echo " test_use_statement_error.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_use_statement_error.sh")
fi
else
echo " test_use_statement_error.sh: not found, skipping"
fi
# --- Symlink TOCTOU Tests (Finding F) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Symlink TOCTOU Tests (O_NOFOLLOW in sandboxed opens)"
echo "═══════════════════════════════════════════════════════════"
echo ""
SYMLINK_SCRIPT="tests/security/test_sandbox_symlink_f.sh"
if [ -f "$SYMLINK_SCRIPT" ]; then
if bash "$SYMLINK_SCRIPT" 2>&1; then
echo " test_sandbox_symlink_f.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_sandbox_symlink_f.sh")
fi
else
echo " test_sandbox_symlink_f.sh: not found, skipping"
fi
# --- Stdlib Import Shadowing Tests (Finding E) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Stdlib Import Shadowing Tests (bare import = stdlib)"
echo "═══════════════════════════════════════════════════════════"
echo ""
SHADOW_SCRIPT="tests/security/test_stdlib_shadow_e.sh"
if [ -f "$SHADOW_SCRIPT" ]; then
if bash "$SHADOW_SCRIPT" 2>&1; then
echo " test_stdlib_shadow_e.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_stdlib_shadow_e.sh")
fi
else
echo " test_stdlib_shadow_e.sh: not found, skipping"
fi
# --- Polyglot Exception Taint Tests (Finding D) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Polyglot Exception Taint Tests (error payload tainted)"
echo "═══════════════════════════════════════════════════════════"
echo ""
EXCTAINT_SCRIPT="tests/security/test_polyglot_exception_taint_d.sh"
if [ -f "$EXCTAINT_SCRIPT" ]; then
if bash "$EXCTAINT_SCRIPT" 2>&1; then
echo " test_polyglot_exception_taint_d.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_polyglot_exception_taint_d.sh")
fi
else
echo " test_polyglot_exception_taint_d.sh: not found, skipping"
fi
# --- Governance Function-Reference Tests (Finding C) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Governance Function-Reference Tests (taint via ref calls)"
echo "═══════════════════════════════════════════════════════════"
echo ""
FUNCREF_SCRIPT="tests/security/test_governance_funcref_c.sh"
if [ -f "$FUNCREF_SCRIPT" ]; then
if bash "$FUNCREF_SCRIPT" 2>&1; then
echo " test_governance_funcref_c.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_governance_funcref_c.sh")
fi
else
echo " test_governance_funcref_c.sh: not found, skipping"
fi
# --- Execution Timeout Tests (Findings A+B) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Execution Timeout Tests (--timeout, VM + thread-local)"
echo "═══════════════════════════════════════════════════════════"
echo ""
TIMEOUT_SCRIPT="tests/cli/test_timeout_ab.sh"
if [ -f "$TIMEOUT_SCRIPT" ]; then
if bash "$TIMEOUT_SCRIPT" 2>&1; then
echo " test_timeout_ab.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_timeout_ab.sh")
fi
else
echo " test_timeout_ab.sh: not found, skipping"
fi
# --- Taint Propagation Through Polyglot Blocks (V-VM-001) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Polyglot Taint Propagation Tests (bound input → output)"
echo "═══════════════════════════════════════════════════════════"
echo ""
VM001_SCRIPT="tests/security/test_taint_polyglot_vm001.sh"
if [ -f "$VM001_SCRIPT" ]; then
if bash "$VM001_SCRIPT" 2>&1; then
echo " test_taint_polyglot_vm001.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_taint_polyglot_vm001.sh")
fi
else
echo " test_taint_polyglot_vm001.sh: not found, skipping"
fi
# --- Serialization Depth Limit (V-VM-002) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Serialization Depth Limit Tests (no stack overflow)"
echo "═══════════════════════════════════════════════════════════"
echo ""
VM002_SCRIPT="tests/security/test_serialize_depth_vm002.sh"
if [ -f "$VM002_SCRIPT" ]; then
if bash "$VM002_SCRIPT" 2>&1; then
echo " test_serialize_depth_vm002.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_serialize_depth_vm002.sh")
fi
else
echo " test_serialize_depth_vm002.sh: not found, skipping"
fi
# --- JavaScript Timeout (V-RT-002) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " JavaScript Governance Timeout Tests (--timeout respected)"
echo "═══════════════════════════════════════════════════════════"
echo ""
RT002_SCRIPT="tests/cli/test_js_timeout_rt002.sh"
if [ -f "$RT002_SCRIPT" ]; then
if bash "$RT002_SCRIPT" 2>&1; then
echo " test_js_timeout_rt002.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_js_timeout_rt002.sh")
fi
else
echo " test_js_timeout_rt002.sh: not found, skipping"
fi
# --- Async Worker Timeout (V-ASYNC-001) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Async Timeout Tests (global_shutdown_ visible to workers)"
echo "═══════════════════════════════════════════════════════════"
echo ""
ASYNC001_SCRIPT="tests/cli/test_async_timeout_async001.sh"
if [ -f "$ASYNC001_SCRIPT" ]; then
if bash "$ASYNC001_SCRIPT" 2>&1; then
echo " test_async_timeout_async001.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_async_timeout_async001.sh")
fi
else
echo " test_async_timeout_async001.sh: not found, skipping"
fi
# --- SQLite NULL Safety (V-REG-001) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " SQLite NULL Column Safety Tests (no SIGSEGV on corrupt DB)"
echo "═══════════════════════════════════════════════════════════"
echo ""
REG001_SCRIPT="tests/security/test_sqlite_null_reg001.sh"
if [ -f "$REG001_SCRIPT" ]; then
if bash "$REG001_SCRIPT" 2>&1; then
echo " test_sqlite_null_reg001.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_sqlite_null_reg001.sh")
fi
else
echo " test_sqlite_null_reg001.sh: not found, skipping"
fi
# --- Container Taint Propagation (V-VM-003) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Container Taint Propagation Tests (dict/list mutation)"
echo "═══════════════════════════════════════════════════════════"
echo ""
VM003_SCRIPT="tests/security/test_container_taint_vm003.sh"
if [ -f "$VM003_SCRIPT" ]; then
if bash "$VM003_SCRIPT" 2>&1; then
echo " test_container_taint_vm003.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_container_taint_vm003.sh")
fi
else
echo " test_container_taint_vm003.sh: not found, skipping"
fi
# --- Subprocess Orphan Kill on Timeout (V-RT-003) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Subprocess Orphan Kill Tests (no orphan on timeout)"
echo "═══════════════════════════════════════════════════════════"
echo ""
RT003_SCRIPT="tests/security/test_orphan_kill_rt003.sh"
if [ -f "$RT003_SCRIPT" ]; then
if bash "$RT003_SCRIPT" 2>&1; then
echo " test_orphan_kill_rt003.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_orphan_kill_rt003.sh")
fi
else
echo " test_orphan_kill_rt003.sh: not found, skipping"
fi
# --- Block Source Integrity (V-RT-004) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Block Source Integrity Tests (SHA-256 hash verification)"
echo "═══════════════════════════════════════════════════════════"
echo ""
RT004_SCRIPT="tests/security/test_block_integrity_rt004.sh"
if [ -f "$RT004_SCRIPT" ]; then
if bash "$RT004_SCRIPT" 2>&1; then
echo " test_block_integrity_rt004.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_block_integrity_rt004.sh")
fi
else
echo " test_block_integrity_rt004.sh: not found, skipping"
fi
# --- Python Marshalling Depth Limit (V-RT-005) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Python Marshalling Depth Limit Tests (no SIGSEGV)"
echo "═══════════════════════════════════════════════════════════"
echo ""
RT005_SCRIPT="tests/security/test_marshal_depth_rt005.sh"
if [ -f "$RT005_SCRIPT" ]; then
if bash "$RT005_SCRIPT" 2>&1; then
echo " test_marshal_depth_rt005.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_marshal_depth_rt005.sh")
fi
else
echo " test_marshal_depth_rt005.sh: not found, skipping"
fi
# --- Async Isolation (V-ASYNC-001r) ---
echo ""
echo "═══════════════════════════════════════════════════════════"
echo " Async Isolation Tests (timeout must not contaminate siblings)"
echo "═══════════════════════════════════════════════════════════"
echo ""
ASYNC001R_SCRIPT="tests/security/test_async_isolation_async001r.sh"
if [ -f "$ASYNC001R_SCRIPT" ]; then
if bash "$ASYNC001R_SCRIPT" 2>&1; then
echo " test_async_isolation_async001r.sh: ALL PASSED"
else
FAILED=$((FAILED + 1))
FAILED_TESTS+=("test_async_isolation_async001r.sh")
fi
else
echo " test_async_isolation_async001r.sh: not found, skipping"
fi
# --- Governance String Prefix Stripping (V-GOV-001) ---