| 1 | module document |
| 2 | |
| 3 | import os |
| 4 | |
| 5 | fn testsuite_begin() { |
| 6 | os.chdir(@VMODROOT) or {} |
| 7 | eprintln('>> @VMODROOT: ' + @VMODROOT) |
| 8 | } |
| 9 | |
| 10 | fn test_get_parent_mod_on_root_folder() { |
| 11 | // TODO: add an equivalent windows check for c:\ |
| 12 | $if !windows { |
| 13 | assert '---' == get_parent_mod('/') or { |
| 14 | assert err.msg() == 'root folder reached' |
| 15 | '---' |
| 16 | } |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | fn test_get_parent_mod_current_folder() { |
| 21 | // TODO: this should may be return '' reliably on windows too: |
| 22 | // assert '' == get_parent_mod('.') or { |
| 23 | // assert err.msg() == 'No V files found.' |
| 24 | // '---' |
| 25 | // } |
| 26 | } |
| 27 | |
| 28 | fn test_get_parent_mod_on_temp_dir() { |
| 29 | // TODO: fix this on windows |
| 30 | $if !windows { |
| 31 | assert get_parent_mod(os.temp_dir())! == '' |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | fn test_get_parent_mod_normal_cases() { |
| 36 | assert '---' == get_parent_mod(os.join_path(@VMODROOT, 'vlib/v')) or { |
| 37 | assert err.msg() == 'No V files found.' |
| 38 | '---' |
| 39 | } |
| 40 | assert get_parent_mod(os.join_path(@VMODROOT, 'vlib', 'v', 'token'))! == 'v' |
| 41 | assert get_parent_mod(os.join_path(@VMODROOT, 'vlib', 'os', 'os.v'))! == 'os' |
| 42 | assert get_parent_mod(os.join_path(@VMODROOT, 'cmd'))! == '' |
| 43 | assert get_parent_mod(os.join_path(@VMODROOT, 'cmd', 'tools', 'modules', 'testing', 'common.v'))! == 'tools.modules.testing' |
| 44 | } |
| 45 | |