Debian Codegraph @

testsuite/modules.00-init/170-cwd.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.00-init/%M%
6 # Revision: %I%
7 # First Edition: 2022/05/20
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command:
14 # Sub-Command:
15 #
16 # Comment: %C{
17 # Check current working directory retrieval error
18 # }C%
19 #
20 ##############################################################################
21
22 skip_if_quick_mode
23
24 # test execution of modulecmd from a removed current working directory
25 # skip this test in the following situation:
26 # - when coverage is enabled, as the cwd error will be caught by coverage tool
27 # rather than getAbsolutePath procedure. The next test (pwd supersede) enable
28 # coverage check of getAbsolutePath
29 # - when running on Cygwin/MinGW/MSYS which are unaffected by cwd removal
30 # - when running on Tcl 8.5 where test outputs are saved in files located in
31 # current working directory
32 if {![info exists env(COVERAGE)] && $os_name ni {cygwin mingw msys}\
33 && [cmpversion $tclsh_version 8.6] > -1} {
34
35 # change MODULECMD for the test to make it an absolute path name
36 set MODULECMD $env(TESTSUITEDIR)/../$MODULECMD
37
38 # create a temporary current working directory and remove it after changing to it
39 file mkdir cwdtest
40 cd cwdtest
41 file delete ../cwdtest
42
43 set tserr "$error_msgs: error getting working directory name: no such file or directory"
44 testouterr_cmd sh {load ./unk} ERR $tserr
45
46 # move back to testsuite working directory
47 cd $ORIG_CWD
48 set MODULECMD $ORIG_MODULECMD
49 }
50
51 # test pwd error catch in getAbsolutePath for coverage mode by superseding
52 # the pwd procedure
53 if {[siteconfig_isStderrTty]} {
54 setenv_var TESTSUITE_ENABLE_SITECONFIG_PWDERROR 1
55 set tserr "$error_msgs: Custom error message"
56 testouterr_cmd sh {load ./unk} ERR $tserr
57 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_PWDERROR
58 }
59
60
61 #
62 # Clean up variables used in this test case
63 #
64
65 reset_test_env