text: // Copyright (c) 2017-2020, Lawrence Livermore National Security, LLC and
  // other Axom Project Developers. See the top-level COPYRIGHT file for details.
  //
  // SPDX-License-Identifier: (BSD-3-Clause)
  
  #include "gtest/gtest.h"
  #include <fstream>
  
  #include "axom/config.hpp"
  #include "axom/core/utilities/FileUtilities.hpp"
  
  namespace fs = axom::utilities::filesystem;
  
  TEST(core_fileUtilities,getCWD_smoke)
  {
    // This test just checks that we can call the getCWD function
    // It does not in any way confirm the results
  
    std::cout<<"Checking that we can call getCWD()" << std::endl;
  
    std::string cwd = fs::getCWD();
  
    std::cout <<" CWD is: " << cwd << std::endl;
  
    SUCCEED();
  }
  
  TEST(core_fileUtilities,joinPath)
  {
    std::cout<< "Testing joinPath() function" << std::endl;
  
    std::string fdir = "abc";
    std::string fdirWithSlash = "abc/";
    std::string fname = "def";
  
    std::string fullfile = "abc/def";
  
    EXPECT_EQ( fullfile, fs::joinPath( fdir,fname) );
  
    EXPECT_EQ( fullfile, fs::joinPath( fdirWithSlash,fname) );
  
  
    std::string fnameWithSubdir = "def/ghi";
    EXPECT_EQ( "abc/def/ghi", fs::joinPath( fdir,fnameWithSubdir) );
  
  }
  
  
  TEST(core_fileUtilities,pathExists)
  {
    std::cout<<"Testing pathExists() function" << std::endl;
  
    std::string cwd = fs::getCWD();
  
    // Test file that we know is present (i.e. the working directory)
    {
      EXPECT_TRUE( fs::pathExists(cwd) );
    }
  
    // Test on file that we know is not present
    {
      const std::string missing = "m_i_s_s_i_n_g__f_i_l_e";
      EXPECT_FALSE( fs::pathExists( fs::joinPath(cwd,missing) ) );
    }
  
    // Test a file relative to AXOM_SRC_DIR
    {
      EXPECT_TRUE( fs::pathExists(AXOM_SRC_DIR));
  
      std::string dataDir = fs::joinPath(AXOM_SRC_DIR, "axom");
      EXPECT_TRUE( fs::pathExists(dataDir));
  
      std::string fileName = fs::joinPath(dataDir, "config.hpp.in");
      EXPECT_TRUE( fs::pathExists(fileName));
    }
  }
  
  TEST(core_fileUtilities,changeCWD_smoke)
  {
    std::cout<<"Testing 'changeCWD()'" << std::endl;
  
    // Save copy of cwd at start of test
    std::string origCWD = fs::getCWD();
    std::cout<<"[Original cwd]: '" << origCWD <<"'" << std::endl;
  
    // Update cwd to new directory
    std::string newCWD = AXOM_SRC_DIR;
    EXPECT_TRUE( fs::pathExists(newCWD) );
    std::cout<<"Changing directory to: '" << newCWD <<"'" << std::endl;
  
    int rc = fs::changeCWD(newCWD);
    EXPECT_EQ(0, rc);
    std::cout<<"[Updated cwd]: '" << fs::getCWD() <<"'" << std::endl;
  
    // Note: newCWD might contain symbolic links,
    // so don't directly compare newCWD and getCWD()
    if(origCWD != newCWD)
    {
      EXPECT_NE(origCWD, fs::getCWD() );
    }
  
    // Change back to original directory
    rc = fs::changeCWD(origCWD);
    EXPECT_EQ(0, rc);
  
    EXPECT_EQ(origCWD, fs::getCWD() );
    std::cout<<"[cwd after change]: '" << fs::getCWD() <<"'" << std::endl;
  
  }
  