From 9841fd8bec74e636904d700050154876a9ae243d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Tup=C3=BD?= Date: Wed, 31 Jan 2024 21:31:44 +0100 Subject: [PATCH] Cleanup. --- source/tests/app_STDERR.txt | 0 source/tests/app_STDOUT.txt | 1 - source/tests/main.cpp | 26 +++++++++++++++++++++++++- source/utility/filesystem/file.h | 6 ++++++ 4 files changed, 31 insertions(+), 2 deletions(-) delete mode 100644 source/tests/app_STDERR.txt delete mode 100644 source/tests/app_STDOUT.txt diff --git a/source/tests/app_STDERR.txt b/source/tests/app_STDERR.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/source/tests/app_STDOUT.txt b/source/tests/app_STDOUT.txt deleted file mode 100644 index 08839f6b..00000000 --- a/source/tests/app_STDOUT.txt +++ /dev/null @@ -1 +0,0 @@ -200 diff --git a/source/tests/main.cpp b/source/tests/main.cpp index 6194eb14..37742392 100644 --- a/source/tests/main.cpp +++ b/source/tests/main.cpp @@ -131,6 +131,26 @@ i32 run_all_tests(const parametric::parameters& params) { std::queue paths({ test_directory.get_canonical_path() }); bool encountered_error = false; + // initialize our files + try { + utility::fs::create(COMPILER_STDOUT); + utility::fs::create(COMPILER_STDERR); + utility::fs::create(CLANG_STDOUT); + utility::fs::create(CLANG_STDERR); + utility::fs::create(APP_STDOUT); + utility::fs::create(APP_STDERR); + utility::fs::create(OBJECT_FILE); + utility::fs::create(EXECUTABLE_FILE); + } + catch (const std::exception& exception) { + utility::console::printerr("error: {}\n", exception.what()); + encountered_error = true; + } + + if(encountered_error) { + return 1; + } + // run our tests try { while (!paths.empty()) { @@ -147,7 +167,7 @@ i32 run_all_tests(const parametric::parameters& params) { // only compile .s files encountered_error |= run_test(path, compiler_path); } - }); + }); } } catch (const std::exception& exception) { @@ -159,6 +179,10 @@ i32 run_all_tests(const parametric::parameters& params) { try { utility::fs::remove(COMPILER_STDOUT); utility::fs::remove(COMPILER_STDERR); + utility::fs::remove(CLANG_STDOUT); + utility::fs::remove(CLANG_STDERR); + utility::fs::remove(APP_STDOUT); + utility::fs::remove(APP_STDERR); utility::fs::remove(OBJECT_FILE); utility::fs::remove(EXECUTABLE_FILE); } diff --git a/source/utility/filesystem/file.h b/source/utility/filesystem/file.h index 3a6a3d91..b9a6d876 100644 --- a/source/utility/filesystem/file.h +++ b/source/utility/filesystem/file.h @@ -68,5 +68,11 @@ namespace utility { inline auto remove(const filepath& path) -> bool { return std::filesystem::remove(path.get_path()); } + + void create(const filepath& path) { + // TODO: add error checking + std::ofstream file(path.get_path()); + file.close(); + } } } // namespace utility::fs