@@ -3,83 +3,73 @@ set -euo pipefail
33
44cd " $( dirname " $0 " ) "
55
6- # Files that V1 may clobber during rebuild — backup and restore around v builds.
7- # Use unique suffixes to avoid name collisions (e.g. two types.v files).
6+ # V1's formatter may clobber v2 source files during rebuild.
7+ # Back up the entire v2 tree and restore after each V1 build.
8+ V2_SRC=" ../../vlib/v2"
9+ V2_BAK=" /tmp/v2_src_bak_test_all"
10+
811backup_v2_src () {
9- cp ../../vlib/v2/gen/cleanc/consts_and_globals.v /tmp/bak_ta_cleanc_consts.v
10- cp ../../vlib/v2/gen/cleanc/assign.v /tmp/bak_ta_cleanc_assign.v
11- cp ../../vlib/v2/ssa/module.v /tmp/bak_ta_ssa_module.v
12- cp ../../vlib/v2/ssa/optimize/mem2reg.v /tmp/bak_ta_ssa_mem2reg.v
13- cp ../../vlib/v2/transformer/struct.v /tmp/bak_ta_tr_struct.v
14- cp ../../vlib/v2/transformer/transformer.v /tmp/bak_ta_tr_transformer.v
15- cp ../../vlib/v2/transformer/types.v /tmp/bak_ta_tr_types.v
12+ rm -rf " $V2_BAK "
13+ cp -R " $V2_SRC " " $V2_BAK "
1614}
1715
1816restore_v2_src () {
19- cp /tmp/bak_ta_cleanc_consts.v ../../vlib/v2/gen/cleanc/consts_and_globals.v
20- cp /tmp/bak_ta_cleanc_assign.v ../../vlib/v2/gen/cleanc/assign.v
21- cp /tmp/bak_ta_ssa_module.v ../../vlib/v2/ssa/module.v
22- cp /tmp/bak_ta_ssa_mem2reg.v ../../vlib/v2/ssa/optimize/mem2reg.v
23- cp /tmp/bak_ta_tr_struct.v ../../vlib/v2/transformer/struct.v
24- cp /tmp/bak_ta_tr_transformer.v ../../vlib/v2/transformer/transformer.v
25- cp /tmp/bak_ta_tr_types.v ../../vlib/v2/transformer/types.v
17+ rsync -a --delete " $V2_BAK /" " $V2_SRC /"
2618}
2719
2820KNOWN_FAILURES=0
2921
30- echo " === 1/13: ARM64 self-host hello world ==="
31- if v -o v2 v2.v && ./v2 -backend arm64 -nocache -o v3 v2.v && ./v3 -o hello_arm hello.v && ./hello_arm; then
32- echo " [PASS]"
33- else
34- echo " [KNOWN FAILURE] ARM64 self-host — skipping"
35- KNOWN_FAILURES=$(( KNOWN_FAILURES + 1 ))
36- fi
22+ echo " === 1/14: ARM64 self-host hello world ==="
23+ backup_v2_src
24+ v -skip-unused -cc cc -o v2 v2.v
25+ restore_v2_src
26+ ./v2 -backend arm64 -nocache -o v3 v2.v && ./v3 -o hello_arm hello.v && ./hello_arm
3727
3828echo " "
39- echo " === 2/13: Self-host test ==="
40- if bash test_v2_self.sh; then
41- echo " [PASS]"
29+ echo " === 2/14: ARM64 self-host chain (v2->v3->v4->v5, parallel) ==="
30+ echo " Building v3 from v2..."
31+ ./v2 -nocache -backend arm64 -o v3_chain v2.v
32+ echo " Building v4 from v3..."
33+ ./v3_chain -nocache -gc none -backend arm64 -o v4_chain v2.v
34+ echo " Building v5 from v4..."
35+ ./v4_chain -nocache -gc none -backend arm64 -o v5_chain v2.v
36+ V4_SIZE=$( wc -c < v4_chain)
37+ V5_SIZE=$( wc -c < v5_chain)
38+ if [ " $V4_SIZE " -eq " $V5_SIZE " ]; then
39+ echo " v4=v5 ($V4_SIZE bytes) — chain converged"
4240else
43- echo " [KNOWN FAILURE] Self-host test — skipping "
44- KNOWN_FAILURES= $(( KNOWN_FAILURES + 1 ))
41+ echo " FAIL: v4 ( $V4_SIZE ) != v5 ( $V5_SIZE ) "
42+ exit 1
4543fi
44+ rm -f v3_chain v4_chain v5_chain
45+
46+ echo " "
47+ echo " === 3/14: Self-host test ==="
48+ bash test_v2_self.sh
4649
4750echo " "
48- echo " === 3/13: Rebuild v2 and run builtin test files ==="
51+ echo " === 4/14: Builtin test files (cleanc) ==="
4952rm -rf /tmp/v2_cleanc_obj_cache
50- backup_v2_src
51- v self && v -skip-unused -cc cc -o v2 v2.v
52- restore_v2_src
5353./v2 ../../vlib/builtin/array_test.v
5454./v2 ../../vlib/builtin/string_test.v
5555./v2 ../../vlib/builtin/map_test.v
5656
5757echo " "
58- echo " === 4/13: Builtin test files (arm64) ==="
59- if ./v2 -backend arm64 ../../vlib/builtin/array_test.v \
60- && ./v2 -backend arm64 ../../vlib/builtin/string_test.v \
61- && ./v2 -backend arm64 ../../vlib/builtin/map_test.v; then
62- echo " [PASS]"
63- else
64- echo " [KNOWN FAILURE] ARM64 builtin tests — skipping"
65- KNOWN_FAILURES=$(( KNOWN_FAILURES + 1 ))
66- fi
58+ echo " === 5/14: Builtin test files (arm64) ==="
59+ ./v2 -backend arm64 ../../vlib/builtin/array_test.v
60+ ./v2 -backend arm64 ../../vlib/builtin/string_test.v
61+ ./v2 -backend arm64 ../../vlib/builtin/map_test.v
6762
6863echo " "
69- echo " === 5/13 : Math test ==="
64+ echo " === 6/14 : Math test ==="
7065./v2 ../../vlib/math/math_test.v
7166
7267echo " "
73- echo " === 6/13: Math test (arm64) ==="
74- if ./v2 -backend arm64 ../../vlib/math/math_test.v; then
75- echo " [PASS]"
76- else
77- echo " [KNOWN FAILURE] ARM64 math test — skipping"
78- KNOWN_FAILURES=$(( KNOWN_FAILURES + 1 ))
79- fi
68+ echo " === 7/14: Math test (arm64) ==="
69+ ./v2 -backend arm64 ../../vlib/math/math_test.v
8070
8171echo " "
82- echo " === 7/13 : Sumtype tests ==="
72+ echo " === 8/14 : Sumtype tests ==="
8373./v2 test_sumtype.v
8474./v2 test_sumtype2.v
8575./v2 test_sumtype3.v
@@ -92,7 +82,7 @@ echo "=== 7/13: Sumtype tests ==="
9282./v2 test_sumtype_global.v
9383
9484echo " "
95- echo " === 8/13 : Sumtype tests (arm64) ==="
85+ echo " === 9/14 : Sumtype tests (arm64) ==="
9686./v2 -backend arm64 test_sumtype.v
9787./v2 -backend arm64 test_sumtype2.v
9888./v2 -backend arm64 test_sumtype3.v
@@ -105,28 +95,23 @@ echo "=== 8/13: Sumtype tests (arm64) ==="
10595./v2 -backend arm64 test_sumtype_global.v
10696
10797echo " "
108- echo " === 9/13 : SSA backends test (arm64) ==="
98+ echo " === 10/14 : SSA backends test (arm64) ==="
10999v -gc none run test_ssa_backends.v arm64
110100
111101echo " "
112- echo " === 10/13 : SSA backends test (cleanc) ==="
102+ echo " === 11/14 : SSA backends test (cleanc) ==="
113103v -gc none run test_ssa_backends.v cleanc
114104
115105echo " "
116- echo " === 11/13: Transformer unit tests ==="
117- if v ../../vlib/v2/transformer/transformer_test.v; then
118- echo " [PASS]"
119- else
120- echo " [KNOWN FAILURE] Transformer unit tests — skipping"
121- KNOWN_FAILURES=$(( KNOWN_FAILURES + 1 ))
122- fi
106+ echo " === 12/14: Transformer unit tests ==="
107+ v ../../vlib/v2/transformer/transformer_test.v
123108
124109echo " "
125- echo " === 12/13 : Transformer integration test ==="
110+ echo " === 13/14 : Transformer integration test ==="
126111v ../../vlib/v2/transformer/transformer_v2_darwin_test.v
127112
128113echo " "
129- echo " === 13/13 : Cleanc runtime tests ==="
114+ echo " === 14/14 : Cleanc runtime tests ==="
130115v -gc none run ../../vlib/v2/gen/cleanc/tests/run_tests.v
131116
132117echo " "
0 commit comments