Luna/tests/run-tests.cpp
apio d589834eb7
All checks were successful
continuous-integration/drone/push Build is passing
libluna: Add HashTable
2023-06-15 15:50:04 +02:00

33 lines
898 B
C++

#include <luna/String.h>
#include <os/ArgumentParser.h>
#include <os/Directory.h>
#include <os/File.h>
#include <stdlib.h>
#include <sys/wait.h>
Result<int> luna_main(int argc, char** argv)
{
StringView test_dir;
os::ArgumentParser parser;
parser.add_description("Run the system test suite.");
parser.add_system_program_info("run-tests"_sv);
parser.add_positional_argument(test_dir, "test-dir", "/bin/tests"_sv);
parser.parse(argc, argv);
auto dir = TRY(os::Directory::open(test_dir));
auto files = TRY(dir->list_names(os::Directory::Filter::Hidden));
for (const auto& program : files)
{
auto command = TRY(String::format("%s/%s"_sv, test_dir.chars(), program.chars()));
int status = system(command.chars());
if (WEXITSTATUS(status) != 0) return WEXITSTATUS(status);
}
os::println("All tests passed.");
return 0;
}