|
| 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)] && ![regexp {^(CYGWIN|MINGW|MSYS_NT).*}\ |
| 33 | + $tcl_platform(os)] && [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 | + set ORIG_CWD [pwd] |
| 40 | + file mkdir cwdtest |
| 41 | + cd cwdtest |
| 42 | + file delete ../cwdtest |
| 43 | + |
| 44 | + set tserr "$error_msgs: error getting working directory name: no such file or directory" |
| 45 | + testouterr_cmd sh {load ./unk} ERR $tserr |
| 46 | + |
| 47 | + # move back to testsuite working directory |
| 48 | + cd $ORIG_CWD |
| 49 | + unset MODULECMD |
| 50 | +} |
| 51 | + |
| 52 | +# test pwd error catch in getAbsolutePath for coverage mode by superseding |
| 53 | +# the pwd procedure |
| 54 | +if {[siteconfig_isStderrTty]} { |
| 55 | + setenv_var TESTSUITE_ENABLE_SITECONFIG_PWDERROR 1 |
| 56 | + set tserr "$error_msgs: Custom error message" |
| 57 | + testouterr_cmd sh {load ./unk} ERR $tserr |
| 58 | + unsetenv_var TESTSUITE_ENABLE_SITECONFIG_PWDERROR |
| 59 | +} |
| 60 | + |
| 61 | + |
| 62 | +# |
| 63 | +# Clean up variables used in this test case |
| 64 | +# |
| 65 | + |
| 66 | +reset_test_env |
0 commit comments