From 79892344b86454e8e7f576d7f2790d3923a4ff5f Mon Sep 17 00:00:00 2001 From: acpaquette Date: Tue, 9 Jan 2024 22:04:03 -0700 Subject: [PATCH 1/4] Fixed env var expansion to include underscores --- isis/src/base/objs/FileName/FileName.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/isis/src/base/objs/FileName/FileName.cpp b/isis/src/base/objs/FileName/FileName.cpp index 8927da9636..425e0801a5 100644 --- a/isis/src/base/objs/FileName/FileName.cpp +++ b/isis/src/base/objs/FileName/FileName.cpp @@ -846,7 +846,7 @@ namespace Isis { // Loop while there are any "$" at the current position or after // Some "$" might be skipped if no translation can be found while((varStartPos = expandedStr.indexOf("$", varSearchStartPos)) != -1) { - int varEndPos = expandedStr.indexOf(QRegExp("[^a-zA-Z{}0-9]"), varStartPos + 1); + int varEndPos = expandedStr.indexOf(QRegExp("[^a-zA-Z{}0-9_]"), varStartPos + 1); if (varEndPos == -1) varEndPos = expandedStr.length(); From 67fe160de2ba67737d229a6b204f938bd0601535 Mon Sep 17 00:00:00 2001 From: acpaquette Date: Tue, 9 Jan 2024 22:21:01 -0700 Subject: [PATCH 2/4] Added test to cover change --- isis/tests/FileNameTests.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/isis/tests/FileNameTests.cpp b/isis/tests/FileNameTests.cpp index fc8aa4b345..ad63edaf2e 100644 --- a/isis/tests/FileNameTests.cpp +++ b/isis/tests/FileNameTests.cpp @@ -84,13 +84,21 @@ TEST(FileName, Extension) { EXPECT_EQ("cub", file.extension()); } -TEST(FileName, Expanded) { +TEST(FileName, Expanded1) { QString relativeFileName("test.cub"); FileName file("$ISISROOT/" + relativeFileName); QString isisRoot(getenv("ISISROOT")); EXPECT_EQ(isisRoot + "/" + relativeFileName, file.expanded()); } +TEST(FileName, Expanded2) { + QString relativeFileName("test.cub"); + setenv("SOME_FILE_PATH", getenv("ISISROOT"), 1); + FileName file("$SOME_FILE_PATH/" + relativeFileName); + QString someFilePath(getenv("ISISROOT")); + EXPECT_EQ(someFilePath + "/" + relativeFileName, file.expanded()); +} + TEST(FileName, Original) { QString test = "$ISISROOT/testy/mc/test/face/test.cub"; FileName file(test); From cf520f619ecefc9e986672a3bfb99c34bae6c188 Mon Sep 17 00:00:00 2001 From: acpaquette Date: Tue, 9 Jan 2024 22:22:59 -0700 Subject: [PATCH 3/4] Added changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54b208fc7a..586552d836 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ release. ### Fixed - Fixed noproj bug where missing shapemodel-related keywords (RayTraceEngine, BulletParts, Tolerance) are dropped when the output label is created. This resulted in the Bullet collision detection engine not being used. Issue: [#5377](https://github.com/USGS-Astrogeology/ISIS3/issues/5377) +- Fixed ISIS failing to expand env variables with an "_" in them. [#5402](https://github.com/DOI-USGS/ISIS3/pull/5402) ## [8.1.0] - 2023-12-05 From 194162aa5c24a5bebb93aeb3a3c8c0be1f71a77d Mon Sep 17 00:00:00 2001 From: acpaquette Date: Fri, 12 Jan 2024 13:59:12 -0700 Subject: [PATCH 4/4] Renamed tests --- isis/tests/FileNameTests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/isis/tests/FileNameTests.cpp b/isis/tests/FileNameTests.cpp index ad63edaf2e..ce19019a71 100644 --- a/isis/tests/FileNameTests.cpp +++ b/isis/tests/FileNameTests.cpp @@ -84,14 +84,14 @@ TEST(FileName, Extension) { EXPECT_EQ("cub", file.extension()); } -TEST(FileName, Expanded1) { +TEST(FileName, ExpandedDefault) { QString relativeFileName("test.cub"); FileName file("$ISISROOT/" + relativeFileName); QString isisRoot(getenv("ISISROOT")); EXPECT_EQ(isisRoot + "/" + relativeFileName, file.expanded()); } -TEST(FileName, Expanded2) { +TEST(FileName, ExpandedUnderscore) { QString relativeFileName("test.cub"); setenv("SOME_FILE_PATH", getenv("ISISROOT"), 1); FileName file("$SOME_FILE_PATH/" + relativeFileName);