Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fmt: fix removal of used selective and alias imports in modules in `$…
…VMODULES` dirs (#20977)
- Loading branch information
Showing
2 changed files
with
33 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
|
||
const vexe = os.quoted_path(@VEXE) | ||
const vmodules_tdir = os.join_path(os.vtmp_dir(), 'fmt_vmodules_test') | ||
const module_tdir = os.join_path(vmodules_tdir, 'foo') | ||
|
||
fn testsuite_begin() { | ||
os.mkdir_all(module_tdir) or {} | ||
os.setenv('VMODULES', vmodules_tdir, true) | ||
} | ||
|
||
fn testsuite_end() { | ||
os.rmdir_all(vmodules_tdir) or {} | ||
} | ||
|
||
fn test_fmt_vmodules() { | ||
tfile_content := [ | ||
'import x.json2 as json', | ||
'import datatypes { Stack }', | ||
'', | ||
'const foo = Stack[string]{}', | ||
'', | ||
].join_lines() | ||
os.write_file(os.join_path(module_tdir, 'main.v'), tfile_content)! | ||
os.execute_opt('${vexe} fmt -c ${module_tdir}') or { assert false, err.msg() } | ||
} |