Skip to content

Commit d6d0cf8

Browse files
committed
removed erroneous newline from terse spider output, fixed asymmetry where prereqs where printed when terse spider found single matching module
1 parent daec54b commit d6d0cf8

File tree

11 files changed

+59
-29
lines changed

11 files changed

+59
-29
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Prerequisite module for testing dependencies in terse spider
2+
setenv("GCC_VERSION", myModuleVersion())
3+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Prerequisite module for testing dependencies in terse spider
2+
setenv("GCC_VERSION", myModuleVersion())
3+
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
-- Simple module with no dependencies for testing terse spider output
1+
-- Module with dependencies for testing terse spider output
2+
-- This tests the asymmetry issue: single module should show module name,
3+
-- not prerequisites, in terse mode
4+
depends_on("gcc")
5+
depends_on("intel")
26
setenv("GMP_VERSION", myModuleVersion())
37

8+
9+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
-- Module for testing multiple matches in terse mode
22
setenv("HDF5_VERSION", myModuleVersion())
33

4+
5+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
-- Module for testing multiple matches in terse mode
22
setenv("HDF5_VERSION", myModuleVersion())
33

4+
5+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Prerequisite module for testing dependencies in terse spider
2+
setenv("INTEL_VERSION", myModuleVersion())
3+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Prerequisite module for testing dependencies in terse spider
2+
setenv("INTEL_VERSION", myModuleVersion())
3+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Prerequisite module for testing dependencies in terse spider
2+
setenv("INTEL_VERSION", myModuleVersion())
3+

rt/terse_spider/terse_spider.tdesc

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ testdescript = {
77
description = [[
88
Test terse mode output for spider command:
99
1. Single module match should output just module name (not verbose format)
10-
2. Non-existent module should output nothing (no error message)
10+
2. Single module with dependencies should show module name, not prerequisites
11+
3. Multiple module matches should output module names (one per line)
12+
4. No blank line at end of output
13+
5. Non-existent module should output nothing (no error message, no blank line)
1114
]],
1215
keywords = {testName, "spider", "terse"},
1316

@@ -28,26 +31,25 @@ testdescript = {
2831
2932
runLmod --version # 1
3033
31-
# Bug 1: Single module match in terse mode should output just module name
32-
# Expected: gmp/6.3.0 (single line, no verbose formatting)
34+
# Test 1: Single module match in terse mode should output just module name
35+
# Expected: gmp/6.3.0 (single line, no verbose formatting, no blank line)
36+
# This tests the asymmetry fix: single module should show module name,
37+
# not prerequisites, even when dependencies exist
3338
runLmod -t spider gmp # 2
3439
35-
# Bug 1: Multiple module matches should still work correctly
36-
# Expected: hdf5/1.14.4\nhdf5/1.14.6 (one per line)
40+
# Test 2: Multiple module matches should output module names (one per line)
41+
# Expected: hdf5/1.14.4\nhdf5/1.14.6 (one per line, no blank line at end)
42+
# This tests that multiple modules work correctly and no blank line appears
3743
runLmod -t spider hdf5 # 3
3844
39-
# Bug 2: Non-existent module in terse mode should output nothing
40-
# Expected: (empty output, no error message)
45+
# Test 3: Non-existent module in terse mode should output nothing
46+
# Expected: (empty output, no error message, no blank line)
47+
# This verifies no blank line issue and proper handling of non-existent modules
4148
runLmod -t spider alps # 4
4249
43-
# Bug 2: Non-existent module in non-terse mode should show error
50+
# Test 4: Non-existent module in non-terse mode should show error
4451
# Expected: Error message (to verify non-terse mode still works)
4552
runLmod spider alps # 5
46-
47-
# Bug 1: Verify single module with dependencies still works in terse mode
48-
# (This should still show dependencies, not just module name)
49-
# Note: We don't have a module with dependencies in this test, but we can
50-
# verify that the existing behavior for modules without deps is fixed
5153
5254
HOME=$ORIG_HOME
5355
@@ -74,3 +76,5 @@ testdescript = {
7476

7577
}
7678

79+
80+

src/Spider.lua

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ function M._Level1(self, dbT, providedByT, possibleA, sn, key, helpFlg)
12251225
if ((m_count == 1 and p_count == 0) or (m_count == 0 and p_count == 1) or
12261226
(numNames == 1)) then
12271227
--io.stderr:write("going level 2: fullName: ",fullName,"\n")
1228-
local s = self:_Level2(sn, fullName, entryMA, entryPA, possibleA, tailMsg)
1228+
local s = self:_Level2(sn, fullName, entryMA, entryPA, possibleA, tailMsg, key)
12291229
dbg.fini("Spider:_Level1")
12301230
return s
12311231
end
@@ -1349,8 +1349,8 @@ function M._Level1(self, dbT, providedByT, possibleA, sn, key, helpFlg)
13491349
return concatTbl(a,"")
13501350
end
13511351

1352-
function M._Level2(self, sn, fullName, entryA, entryPA, possibleA, tailMsg)
1353-
dbg.start{"Spider:_Level2(\"",sn,"\", \"",fullName,"\", entryA, entryPA, possibleA, tailMsg)"}
1352+
function M._Level2(self, sn, fullName, entryA, entryPA, possibleA, tailMsg, key)
1353+
dbg.start{"Spider:_Level2(\"",sn,"\", \"",fullName,"\", entryA, entryPA, possibleA, tailMsg, key: \"",key or "nil","\")"}
13541354
--dbg.printT("entryA",entryA)
13551355

13561356
local optionTbl = optionTbl()
@@ -1380,17 +1380,16 @@ function M._Level2(self, sn, fullName, entryA, entryPA, possibleA, tailMsg)
13801380
dbg.printT("entryA[1]", entryT)
13811381
dbg.printT("entryPA", entryPA)
13821382

1383-
-- Early return for terse mode when no dependencies
1384-
if (terse and next(entryA) ~= nil) then
1385-
local hasDependencies = false
1386-
for k = 1, #entryA do
1387-
if (entryA[k].parentAA) then
1388-
hasDependencies = true
1389-
break
1390-
end
1391-
end
1392-
if (not hasDependencies) then
1393-
-- Return just the module name, consistent with _Level1 terse output
1383+
-- Early return for terse mode:
1384+
-- - If user searched for a specific module/version (key == fullName), show prerequisites
1385+
-- - If user searched for a module name and got one match (key != fullName), show module name
1386+
-- This fixes the asymmetry issue while preserving the expected behavior for specific version searches
1387+
if (terse and fullName and (next(entryA) ~= nil or next(entryPA) ~= nil)) then
1388+
-- If key matches fullName, user searched for specific version - show prerequisites
1389+
if (key and key == fullName) then
1390+
-- Fall through to show prerequisites (existing behavior)
1391+
else
1392+
-- User searched for module name, got one match - show module name (fix asymmetry)
13941393
dbg.fini("Spider:_Level2")
13951394
return fullName .. "\n"
13961395
end

0 commit comments

Comments
 (0)