Skip to content

Commit

Permalink
Fixed Underscore Env Var Expansion (DOI-USGS#5402)
Browse files Browse the repository at this point in the history
* Fixed env var expansion to include underscores

* Added test to cover change

* Added changelog entry

* Renamed tests
  • Loading branch information
acpaquette committed Apr 18, 2024
1 parent cb5929f commit 3168115
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ release.
- Fixed a bug in which 'version' file was compiled as source and prevented subsequent ISIS recompilation [#5374](https://github.com/DOI-USGS/ISIS3/issues/5374)
- Fixed <i>noproj</i> bug where some temporary files were not deleted after call to cam2cam. Issue: [#4813](https://github.com/USGS-Astrogeology/ISIS3/issues/4813)
- Fixed <i>noproj</i> 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.0.2] - 2023-12-05
### Changed
Expand Down
2 changes: 1 addition & 1 deletion isis/src/base/objs/FileName/FileName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
10 changes: 9 additions & 1 deletion isis/tests/FileNameTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,21 @@ TEST(FileName, Extension) {
EXPECT_EQ("cub", file.extension());
}

TEST(FileName, Expanded) {
TEST(FileName, ExpandedDefault) {
QString relativeFileName("test.cub");
FileName file("$ISISROOT/" + relativeFileName);
QString isisRoot(getenv("ISISROOT"));
EXPECT_EQ(isisRoot + "/" + relativeFileName, file.expanded());
}

TEST(FileName, ExpandedUnderscore) {
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);
Expand Down

0 comments on commit 3168115

Please sign in to comment.