Unverified Commit 62ed4f65 authored by acpaquette's avatar acpaquette Committed by GitHub
Browse files

Fixed Underscore Env Var Expansion (#5402)

* Fixed env var expansion to include underscores

* Added test to cover change

* Added changelog entry

* Renamed tests
parent 12364003
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ release.
### Fixed
- 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.1.0] - 2024-01-08

+1 −1
Original line number Diff line number Diff line
@@ -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();

+9 −1
Original line number Diff line number Diff line
@@ -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);