-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- F Introduce ApprovalFileLog (currently writing to working directory)
- Loading branch information
1 parent
19d4d3b
commit 795f5eb
Showing
5 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "ApprovalFileLog.hpp" | ||
#include <fstream> | ||
|
||
void ApprovalFileLog::initialize() | ||
{ | ||
static bool isInitialized{false}; | ||
if (isInitialized) | ||
{ | ||
return; | ||
} | ||
isInitialized = true; | ||
ApprovalTests::FileUtils::writeToFile(getLogFilePath(), ""); | ||
} | ||
|
||
std::string ApprovalFileLog::getLogFilePath() | ||
{ | ||
//auto const rootDirectory = ApprovalTests::TestName::getRootDirectory(); | ||
auto const rootDirectory = ""; | ||
// Note: Need to figure out where the actual root directory is. | ||
std::string const filePath = | ||
rootDirectory + std::string(APPROVAL_TEMP_DIRECTORY) + "/.approved_files.log"; | ||
ApprovalTests::SystemUtils::ensureDirectoryExists(APPROVAL_TEMP_DIRECTORY); | ||
return filePath; | ||
} | ||
|
||
void ApprovalFileLog::log(const std::string& filePath) | ||
{ | ||
initialize(); | ||
std::ofstream ofs(getLogFilePath(), std::ios::app); | ||
ofs << filePath << std::endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
#include <utilities/FileUtils.h> | ||
#include <utilities/SystemUtils.h> | ||
|
||
auto constexpr APPROVAL_TEMP_DIRECTORY = "/.approval_tests_temp"; | ||
|
||
class ApprovalFileLog { | ||
public: | ||
// Static initializer to ensure an _empty_ log file is created | ||
static void initialize(); | ||
|
||
// Function to get the log file path | ||
static std::string getLogFilePath(); | ||
|
||
// Function to log the approved file path | ||
static void log(const std::string& filePath); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters