fix source-sh test with non-default manpath

Resolves: RHEL-62847
This commit is contained in:
Lukáš Zaoral 2024-10-16 12:42:02 +02:00
parent 972dbe08cb
commit a39cc172bc
No known key found for this signature in database
GPG Key ID: 39157506DD67752D
2 changed files with 140 additions and 2 deletions

View File

@ -0,0 +1,131 @@
From a124745566804f8987a2c68944d395be10591f8c Mon Sep 17 00:00:00 2001
From: Xavier Delaruelle <xavier.delaruelle@cea.fr>
Date: Tue, 15 Oct 2024 07:52:44 +0200
Subject: [PATCH] ts: adapt 50/400 tests when install manpath is default
Fix source-sh tests in 50/400 test case to adapt expected value set to
MANPATH variable when the installed MANPATH value set at configure step
is included in the default MANPATH value set for test.
Fixes #549
---
testsuite/modules.50-cmds/400-source-sh.exp | 46 ++++++++++++++-------
1 file changed, 30 insertions(+), 16 deletions(-)
diff --git a/testsuite/modules.50-cmds/400-source-sh.exp b/testsuite/modules.50-cmds/400-source-sh.exp
index 19a23fb81..753975c2a 100644
--- a/testsuite/modules.50-cmds/400-source-sh.exp
+++ b/testsuite/modules.50-cmds/400-source-sh.exp
@@ -1612,12 +1612,26 @@ if {$install_setmanpath eq {y}} {
} else {
set mandirenc $install_mandir
}
- if {$install_appendmanpath eq {y}} {
- set updatedmanpath $default_manpath:$install_mandir
- set lmsourceshpath "append-path MANPATH $mandirenc|"
- } else {
- set updatedmanpath $install_mandir:$default_manpath
- set lmsourceshpath "prepend-path MANPATH $mandirenc|"
+ set updated_manpath_list [split $default_manpath :]
+ set is_default_manpath_updated 0
+ foreach install_manpath_elt [split $install_mandir :] {
+ if {$install_manpath_elt ni $updated_manpath_list} {
+ if {$install_appendmanpath eq {y}} {
+ lappend updated_manpath_list $install_manpath_elt
+ } else {
+ set updated_manpath_list [linsert $updated_manpath_list 0 $install_manpath_elt]
+ }
+ set is_default_manpath_updated 1
+ }
+ }
+ set updatedmanpath [join $updated_manpath_list :]
+
+ if {$is_default_manpath_updated} {
+ if {$install_appendmanpath eq {y}} {
+ set lmsourceshpath "append-path MANPATH $mandirenc|"
+ } else {
+ set lmsourceshpath "prepend-path MANPATH $mandirenc|"
+ }
}
}
# setup PATH without Modules bin location
@@ -1647,13 +1661,13 @@ if {$install_versioning eq {y}} {
lappend ans [list set MODULE_VERSION_STACK $install_version]
}
# MANPATH is set before PATH if the latter is appended and not the former
-if {$install_setmanpath eq {y} && $install_appendbinpath eq {y} && $install_appendmanpath eq {n}} {
+if {$install_setmanpath eq {y} && $install_appendbinpath eq {y} && $install_appendmanpath eq {n} && $is_default_manpath_updated} {
lappend ans [list set MANPATH $updatedmanpath]
}
if {$install_setbinpath eq {y}} {
lappend ans [list set PATH $updatedpath]
}
-if {$install_setmanpath eq {y} && ($install_appendbinpath eq {n} || $install_appendmanpath eq {y})} {
+if {$install_setmanpath eq {y} && ($install_appendbinpath eq {n} || $install_appendmanpath eq {y}) && $is_default_manpath_updated} {
lappend ans [list set MANPATH $updatedmanpath]
}
lappend ans [list set _LMFILES_ $mp/source-sh/1]
@@ -1703,7 +1717,7 @@ set extratserr {}
set tserr "-------------------------------------------------------------------
$mp/source-sh/1:\n\n"
set tserr_path {}
-if {$install_setmanpath eq {y}} {
+if {$install_setmanpath eq {y} && $is_default_manpath_updated} {
if {$install_appendmanpath eq {y}} {
append tserr_path "append-path\tMANPATH $mandirenc\n"
} else {
@@ -1754,13 +1768,13 @@ if {$install_versioning eq {y}} {
lappend ans [list set MODULE_VERSION_STACK $install_version]
}
# MANPATH is set before PATH if the latter is appended and not the former
-if {$install_setmanpath eq {y} && $install_appendbinpath eq {y} && $install_appendmanpath eq {n}} {
+if {$install_setmanpath eq {y} && $install_appendbinpath eq {y} && $install_appendmanpath eq {n} && $is_default_manpath_updated} {
lappend ans [list set MANPATH $updatedmanpath]
}
if {$install_setbinpath eq {y}} {
lappend ans [list set PATH $updatedpath]
}
-if {$install_setmanpath eq {y} && ($install_appendbinpath eq {n} || $install_appendmanpath eq {y})} {
+if {$install_setmanpath eq {y} && ($install_appendbinpath eq {n} || $install_appendmanpath eq {y}) && $is_default_manpath_updated} {
lappend ans [list set MANPATH $updatedmanpath]
}
lappend ans [list set _LMFILES_ $mp/source-sh/1]
@@ -1792,13 +1806,13 @@ if {$install_versioning eq {y}} {
lappend ans [list set MODULE_VERSION_STACK $install_version]
}
# MANPATH is set before PATH if the latter is appended and not the former
-if {$install_setmanpath eq {y} && $install_appendbinpath eq {y} && $install_appendmanpath eq {n}} {
+if {$install_setmanpath eq {y} && $install_appendbinpath eq {y} && $install_appendmanpath eq {n} && $is_default_manpath_updated} {
lappend ans [list set MANPATH $updatedmanpath]
}
if {$install_setbinpath eq {y}} {
lappend ans [list set PATH $updatedpath]
}
-if {$install_setmanpath eq {y} && ($install_appendbinpath eq {n} || $install_appendmanpath eq {y})} {
+if {$install_setmanpath eq {y} && ($install_appendbinpath eq {n} || $install_appendmanpath eq {y}) && $is_default_manpath_updated} {
lappend ans [list set MANPATH $updatedmanpath]
}
lappend ans [list set _LMFILES_ $modpath/setenv/1.0:$mp/source-sh/1]
@@ -1829,19 +1843,19 @@ setenv_var MODULES_COLLECTION_TARGET bar
if {$install_setbinpath eq {y}} {
setenv_var PATH $updatedpath
}
-if {$install_setmanpath eq {y}} {
+if {$install_setmanpath eq {y} && $is_default_manpath_updated} {
setenv_var MANPATH $updatedmanpath
}
setenv_var __MODULES_LMSOURCESH source-sh/1\&bash\ testsuite/example/sh-to-mod.sh\|${lmsourceshpath}setenv\ MODULES_COLLECTION_TARGET\ bar\|setenv\ testsuite\ yes
set ans [list]
# MANPATH is set before PATH if the latter is appended and not the former
-if {$install_setmanpath eq {y} && $install_appendbinpath eq {y} && $install_appendmanpath eq {n}} {
+if {$install_setmanpath eq {y} && $install_appendbinpath eq {y} && $install_appendmanpath eq {n} && $is_default_manpath_updated} {
lappend ans [list set MANPATH $default_manpath]
}
if {$install_setbinpath eq {y}} {
lappend ans [list set PATH $default_path]
}
-if {$install_setmanpath eq {y} && ($install_appendbinpath eq {n} || $install_appendmanpath eq {y})} {
+if {$install_setmanpath eq {y} && ($install_appendbinpath eq {n} || $install_appendmanpath eq {y}) && $is_default_manpath_updated} {
lappend ans [list set MANPATH $default_manpath]
}
lappend ans [list unset _LMFILES_]

View File

@ -3,13 +3,17 @@
Name: environment-modules
Version: 5.3.1
Release: 5%{?dist}
Release: 6%{?dist}
Summary: Provides dynamic modification of a user's environment
License: GPL-2.0-or-later
URL: http://modules.sourceforge.net/
Source0: http://downloads.sourceforge.net/modules/modules-%{version}.tar.bz2
# fix source-sh test with non-default manpath (RHEL-62847)
# https://github.com/cea-hpc/modules/commit/a124745566804f8987a2c68944d395be10591f8c
Patch0: environment-modules-5.3.1-fix-source-sh-test.patch
BuildRequires: tcl
BuildRequires: dejagnu
BuildRequires: make
@ -61,7 +65,7 @@ have access to the module alias.
%prep
%setup -q -n modules-%{version}
%autosetup -p1 -n modules-%{version}
%build
@ -187,6 +191,9 @@ fi
%changelog
* Wed Oct 16 2024 Lukáš Zaoral <lzaoral@redhat.com> - 5.3.1-6
- fix source-sh test with non-default manpath (RHEL-62847)
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 5.3.1-5
- Bump release for June 2024 mass rebuild