|
19 | 19 | #include "exceptions/Exceptions.hpp" |
20 | 20 |
|
21 | 21 | #include <fstream> |
| 22 | +#include <tinyfiledialogs.h> |
22 | 23 |
|
23 | 24 | #ifdef __linux__ |
24 | 25 | #include <sys/utsname.h> |
@@ -151,18 +152,35 @@ namespace nexo::editor { |
151 | 152 | const auto now_tp = floor<std::chrono::seconds>(std::chrono::system_clock::now()); |
152 | 153 | std::chrono::zoned_time local_zoned{std::chrono::current_zone(), now_tp}; |
153 | 154 | std::string ts = std::format("{:%Y%m%d}", local_zoned); |
154 | | - const std::string filename = std::format("EditorTestResults_{}.report", ts); |
155 | | - |
156 | | - const auto testDir = std::filesystem::path(Path::resolvePathRelativeToExe("../tests/editor")); |
157 | | - std::filesystem::create_directories(testDir); |
158 | | - auto filePath = testDir / filename; |
159 | | - return filePath; |
| 155 | + const std::string filename = std::format("EditorTestResults_{}", ts); |
| 156 | + |
| 157 | + // Tiny file dialog to get path |
| 158 | + // patterns |
| 159 | + const char *patterns[] = {"*.report"}; |
| 160 | + const char *chosenPathStr = tinyfd_saveFileDialog( |
| 161 | + "Save Test Report", |
| 162 | + filename.c_str(), |
| 163 | + 1, |
| 164 | + patterns, |
| 165 | + "Text files (*.report)" |
| 166 | + ); |
| 167 | + if (!chosenPathStr) { |
| 168 | + return std::filesystem::path(); // User cancelled |
| 169 | + } |
| 170 | + const std::filesystem::path chosenPath = chosenPathStr; |
| 171 | + std::filesystem::create_directories(chosenPath.parent_path()); |
| 172 | + return chosenPath; |
160 | 173 | } |
161 | 174 |
|
162 | 175 | void TestWindow::writeTestReport() |
163 | 176 | { |
164 | 177 | const auto filePath = getTestReportFilePath(); |
165 | 178 |
|
| 179 | + if (filePath.empty()) { |
| 180 | + LOG(NEXO_WARN, "Test report generation cancelled by user"); |
| 181 | + return; |
| 182 | + } |
| 183 | + |
166 | 184 | std::ofstream out(filePath.string()); |
167 | 185 | if (!out) { |
168 | 186 | THROW_EXCEPTION(FileWriteException, filePath.string(), nexo::strerror(errno)); |
|
0 commit comments