| 1 | import os |
| 2 | import rand |
| 3 | |
| 4 | const vexe = @VEXE |
| 5 | |
| 6 | fn test_module_in_hyphenated_parent_path_compiles() { |
| 7 | test_root := os.join_path(os.vtmp_dir(), 'hyphenated_module_path_${rand.ulid()}') |
| 8 | module_dir := os.join_path(test_root, 'some-dir', 'somemodule') |
| 9 | os.mkdir_all(module_dir)! |
| 10 | defer { |
| 11 | os.rmdir_all(test_root) or {} |
| 12 | } |
| 13 | os.write_file(os.join_path(module_dir, 'somemodule.v'), 'module somemodule |
| 14 | |
| 15 | pub fn value() int { |
| 16 | return 3 |
| 17 | } |
| 18 | ')! |
| 19 | os.write_file(os.join_path(module_dir, 'some_test.v'), 'module somemodule |
| 20 | |
| 21 | fn test_value() { |
| 22 | assert value() == 3 |
| 23 | } |
| 24 | ')! |
| 25 | old_wd := os.getwd() |
| 26 | defer { |
| 27 | os.chdir(old_wd) or {} |
| 28 | } |
| 29 | os.chdir(test_root)! |
| 30 | module_path := os.join_path('some-dir', 'somemodule') |
| 31 | cmd := '${os.quoted_path(vexe)} test ${os.quoted_path(module_path)}' |
| 32 | res := os.execute(cmd) |
| 33 | if res.exit_code != 0 { |
| 34 | eprintln('> failing test cmd: ${cmd}') |
| 35 | eprintln('> output:\n${res.output}') |
| 36 | } |
| 37 | assert res.exit_code == 0 |
| 38 | } |
| 39 | |