markused: only add .vtest_ functions, *when* compiling _test.v files (#23003)

This commit is contained in:
Delyan Angelov 2024-11-29 02:46:09 +02:00 committed by GitHub
parent c7ee45fc64
commit f2c281eadf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 5 deletions

View file

@ -38,6 +38,15 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Build V - name: Build V
run: make -j4 && ./v symlink run: make -j4 && ./v symlink
- name: Set 8.8.8.8 as dns server
run: |
sudo sed -i 's/#DNS=/DNS=8.8.8.8 8.8.4.4/g' /etc/systemd/resolved.conf
sudo systemctl daemon-reload
sudo systemctl restart systemd-networkd
sudo systemctl restart systemd-resolved
dig distro.ibiblio.org
- name: Install C2V - name: Install C2V
run: | run: |
v retry -- v install --git https://github.com/vlang/c2v v retry -- v install --git https://github.com/vlang/c2v
@ -73,6 +82,15 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Build V - name: Build V
run: make -j4 && ./v symlink run: make -j4 && ./v symlink
- name: Set 8.8.8.8 as dns server
run: |
sudo sed -i 's/#DNS=/DNS=8.8.8.8 8.8.4.4/g' /etc/systemd/resolved.conf
sudo systemctl daemon-reload
sudo systemctl restart systemd-networkd
sudo systemctl restart systemd-resolved
dig distro.ibiblio.org
- name: Install C2V - name: Install C2V
run: | run: |
v retry -- v install --git https://github.com/vlang/c2v v retry -- v install --git https://github.com/vlang/c2v

View file

@ -42,12 +42,9 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
'error', 'error',
'builtin_init', 'builtin_init',
'fast_string_eq', 'fast_string_eq',
// TODO: process the _vinit const initializations automatically too
'main.vtest_init',
'main.vtest_new_metainfo',
'main.vtest_new_filemetainfo',
'println', 'println',
] ]
$if debug_used_features ? { $if debug_used_features ? {
dump(table.used_features) dump(table.used_features)
} }
@ -295,7 +292,7 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
} }
// testing framework: // testing framework:
if pref_.is_test { if pref_.is_test {
if k.starts_with('test_') || k.contains('.test_') { if k.starts_with('test_') || k.contains('.test_') || k.contains('.vtest_') {
all_fn_root_names << k all_fn_root_names << k
continue continue
} }
@ -400,6 +397,7 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
all_fn_root_names << 'time.unix' // used by json all_fn_root_names << 'time.unix' // used by json
table.used_features.used_maps++ // json needs new_map etc table.used_features.used_maps++ // json needs new_map etc
} }
mut walker := Walker.new( mut walker := Walker.new(
table: table table: table
files: ast_files files: ast_files