Skip to content

Commit

Permalink
markused: only add .vtest_ functions, *when* compiling _test.v files (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman authored Nov 29, 2024
1 parent c7ee45f commit f2c281e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/c2v_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ jobs:
- uses: actions/checkout@v4
- name: Build V
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
run: |
v retry -- v install --git https://github.com/vlang/c2v
Expand Down Expand Up @@ -73,6 +82,15 @@ jobs:
- uses: actions/checkout@v4
- name: Build V
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
run: |
v retry -- v install --git https://github.com/vlang/c2v
Expand Down
8 changes: 3 additions & 5 deletions vlib/v/markused/markused.v
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,9 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
'error',
'builtin_init',
'fast_string_eq',
// TODO: process the _vinit const initializations automatically too
'main.vtest_init',
'main.vtest_new_metainfo',
'main.vtest_new_filemetainfo',
'println',
]

$if debug_used_features ? {
dump(table.used_features)
}
Expand Down Expand Up @@ -295,7 +292,7 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
}
// testing framework:
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
continue
}
Expand Down Expand Up @@ -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
table.used_features.used_maps++ // json needs new_map etc
}

mut walker := Walker.new(
table: table
files: ast_files
Expand Down

0 comments on commit f2c281e

Please sign in to comment.