33 lines
892 B
C++
33 lines
892 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(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;
|
||
|
}
|