Skip to content

Commit

Permalink
Deal with windows. current implementation of getParentDirectoryPath e…
Browse files Browse the repository at this point in the history
…xpects makeNativePath beforehand in particular.
  • Loading branch information
jmarrec committed Jan 22, 2021
1 parent 5d3ddd1 commit 5d2a5c3
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions tst/EnergyPlus/unit/FileSystem.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,15 @@ TEST(FileSystem, getAbsolutePath)
TEST(FileSystem, Others)
{
std::string pathName = "folder/FileSystemTest.txt.idf";
// The current implementation of getParentDirectoryPath relies on makeNativePath being called first
EnergyPlus::FileSystem::makeNativePath(pathName);

EXPECT_EQ("idf", EnergyPlus::FileSystem::getFileExtension(pathName));
EXPECT_EQ("folder/FileSystemTest.txt", EnergyPlus::FileSystem::removeFileExtension(pathName));
EXPECT_EQ("folder/", EnergyPlus::FileSystem::getParentDirectoryPath(pathName));
EXPECT_EQ("./", EnergyPlus::FileSystem::getParentDirectoryPath("Myfile.txt.idf"));
std::string root = "./";
EnergyPlus::FileSystem::makeNativePath(root);
EXPECT_EQ(root, EnergyPlus::FileSystem::getParentDirectoryPath("Myfile.txt.idf"));

}

Expand All @@ -137,22 +142,34 @@ TEST(FileSystem, getProgramPath)
std::string programPath = EnergyPlus::FileSystem::getProgramPath();
EXPECT_TRUE(EnergyPlus::FileSystem::pathExists(programPath));
EXPECT_TRUE(programPath.find("energyplus_tests") != std::string::npos);
EXPECT_EQ("energyplus_tests", EnergyPlus::FileSystem::getFileName(programPath));
EXPECT_EQ("energyplus_tests" + EnergyPlus::FileSystem::exeExtension, EnergyPlus::FileSystem::getFileName(programPath));
EXPECT_TRUE(EnergyPlus::FileSystem::directoryExists(EnergyPlus::FileSystem::getParentDirectoryPath(programPath)));
}

TEST(FileSystem, getParentDirectoryPath)
{
EXPECT_EQ("a/b/", EnergyPlus::FileSystem::getParentDirectoryPath("a/b/c"));
EXPECT_EQ("a/b/", EnergyPlus::FileSystem::getParentDirectoryPath("a/b/c/"));
std::string expected = "/a/b/";
EnergyPlus::FileSystem::makeNativePath(expected);

std::string test = "/a/b/c";
EnergyPlus::FileSystem::makeNativePath(test);
EXPECT_EQ(expected, EnergyPlus::FileSystem::getParentDirectoryPath(test));

test = "/a/b/c/";
EnergyPlus::FileSystem::makeNativePath(test);
EXPECT_EQ(expected, EnergyPlus::FileSystem::getParentDirectoryPath(test));
}

TEST(FileSystem, make_and_remove_Directory)
{
fs::remove_all("sandbox");

std::string dirName("sandbox/a");
EXPECT_EQ("sandbox/", EnergyPlus::FileSystem::getParentDirectoryPath(dirName));
EnergyPlus::FileSystem::makeNativePath(dirName);
std::string expected = "sandbox/";
EnergyPlus::FileSystem::makeNativePath(expected);

EXPECT_EQ(expected, EnergyPlus::FileSystem::getParentDirectoryPath(dirName));

EXPECT_FALSE(EnergyPlus::FileSystem::pathExists("sandbox"));
EXPECT_FALSE(EnergyPlus::FileSystem::fileExists("sandbox"));
Expand Down

5 comments on commit 5d2a5c3

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8376_FileSystem_Move_minimal (jmarrec) - x86_64-Linux-Ubuntu-18.04-gcc-7.5: OK (3033 of 3035 tests passed, 0 test warnings)

Messages:\n

  • 1 test had: EIO diffs.
  • 1 test had: ESO small diffs.
  • 1 test had: MTR small diffs.
  • 1 test had: Table big diffs.

Failures:\n

FileSystem Test Summary

  • Passed: 6
  • Failed: 1

regression Test Summary

  • Passed: 735
  • Failed: 1

Build Badge Test Badge

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8376_FileSystem_Move_minimal (jmarrec) - x86_64-MacOS-10.15-clang-11.0.0: OK (2995 of 2995 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8376_FileSystem_Move_minimal (jmarrec) - Win64-Windows-10-VisualStudio-16: OK (2250 of 2252 tests passed, 0 test warnings)

Failures:\n

FileSystem Test Summary

  • Passed: 5
  • Failed: 2

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8376_FileSystem_Move_minimal (jmarrec) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-UnitTestsCoverage-Debug: OK (1561 of 1561 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8376_FileSystem_Move_minimal (jmarrec) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-IntegrationCoverage-Debug: OK (721 of 721 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.