fix test runner
parent
0ce662131b
commit
262e691a4d
|
@ -34,9 +34,9 @@ enum class file_type {
|
||||||
struct file_info;
|
struct file_info;
|
||||||
|
|
||||||
#ifdef OSTD_PLATFORM_WIN32
|
#ifdef OSTD_PLATFORM_WIN32
|
||||||
static constexpr char PathSeparator = '\\';
|
static constexpr char PATH_SEPARATOR = '\\';
|
||||||
#else
|
#else
|
||||||
static constexpr char PathSeparator = '/';
|
static constexpr char PATH_SEPARATOR = '/';
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OSTD_PLATFORM_WIN32
|
#ifdef OSTD_PLATFORM_WIN32
|
||||||
|
@ -157,7 +157,7 @@ private:
|
||||||
}
|
}
|
||||||
string_range r = p_path;
|
string_range r = p_path;
|
||||||
|
|
||||||
string_range found = find_last(r, PathSeparator);
|
string_range found = find_last(r, PATH_SEPARATOR);
|
||||||
if (found.empty()) {
|
if (found.empty()) {
|
||||||
p_slash = std::string::npos;
|
p_slash = std::string::npos;
|
||||||
} else {
|
} else {
|
||||||
|
@ -353,7 +353,7 @@ private:
|
||||||
return file_info();
|
return file_info();
|
||||||
}
|
}
|
||||||
std::string ap = p_path;
|
std::string ap = p_path;
|
||||||
ap += PathSeparator;
|
ap += PATH_SEPARATOR;
|
||||||
ap += static_cast<char const *>(p_de->d_name);
|
ap += static_cast<char const *>(p_de->d_name);
|
||||||
return file_info(ap);
|
return file_info(ap);
|
||||||
}
|
}
|
||||||
|
@ -514,7 +514,7 @@ private:
|
||||||
return file_info();
|
return file_info();
|
||||||
}
|
}
|
||||||
std::string ap = p_path;
|
std::string ap = p_path;
|
||||||
ap += PathSeparator;
|
ap += PATH_SEPARATOR;
|
||||||
ap += static_cast<char const *>(p_data.cFileName);
|
ap += static_cast<char const *>(p_data.cFileName);
|
||||||
return file_info(ap);
|
return file_info(ap);
|
||||||
}
|
}
|
||||||
|
@ -575,7 +575,7 @@ namespace detail {
|
||||||
template<typename T, typename ...A>
|
template<typename T, typename ...A>
|
||||||
static void join(std::string &s, T const &a, A const &...b) {
|
static void join(std::string &s, T const &a, A const &...b) {
|
||||||
s += a;
|
s += a;
|
||||||
s += PathSeparator;
|
s += PATH_SEPARATOR;
|
||||||
path_join<I - 1>::join(s, b...);
|
path_join<I - 1>::join(s, b...);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
#include <ostd/platform.hh>
|
#include <ostd/platform.hh>
|
||||||
#include <ostd/io.hh>
|
#include <ostd/io.hh>
|
||||||
#include <ostd/string.hh>
|
#include <ostd/string.hh>
|
||||||
#include <ostd/map.hh>
|
#include <ostd/unordered_map.hh>
|
||||||
#include <ostd/filesystem.hh>
|
#include <ostd/filesystem.hh>
|
||||||
#include <ostd/environ.hh>
|
#include <ostd/environ.hh>
|
||||||
|
|
||||||
using namespace ostd;
|
using namespace ostd;
|
||||||
|
|
||||||
#ifndef OSTD_PLATFORM_WIN32
|
#ifndef OSTD_PLATFORM_WIN32
|
||||||
constexpr auto ColorRed = "\033[91m";
|
constexpr auto COLOR_RED = "\033[91m";
|
||||||
constexpr auto ColorGreen = "\033[92m";
|
constexpr auto COLOR_GREEN = "\033[92m";
|
||||||
constexpr auto ColorBlue = "\033[94m";
|
constexpr auto COLOR_BLUE = "\033[94m";
|
||||||
constexpr auto ColorBold = "\033[1m";
|
constexpr auto COLOR_BOLD = "\033[1m";
|
||||||
constexpr auto ColorEnd = "\033[0m";
|
constexpr auto COLOR_END = "\033[0m";
|
||||||
#else
|
#else
|
||||||
constexpr auto ColorRed = "";
|
constexpr auto COLOR_RED = "";
|
||||||
constexpr auto ColorGreen = "";
|
constexpr auto COLOR_GREEN = "";
|
||||||
constexpr auto ColorBlue = "";
|
constexpr auto COLOR_BLUE = "";
|
||||||
constexpr auto ColorBold = "";
|
constexpr auto COLOR_BOLD = "";
|
||||||
constexpr auto ColorEnd = "";
|
constexpr auto COLOR_END = "";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
@ -35,35 +35,35 @@ int main() {
|
||||||
/* do not change past this point */
|
/* do not change past this point */
|
||||||
|
|
||||||
int nsuccess = 0, nfailed = 0;
|
int nsuccess = 0, nfailed = 0;
|
||||||
ConstCharRange modname = nullptr;
|
string_range modname = nullptr;
|
||||||
|
|
||||||
auto print_result = [&](ConstCharRange fmsg = nullptr) {
|
auto print_result = [&](string_range fmsg = nullptr) {
|
||||||
write(modname, "...\t");
|
write(modname, "...\t");
|
||||||
if (!fmsg.empty()) {
|
if (!fmsg.empty()) {
|
||||||
writeln(ColorRed, ColorBold, '(', fmsg, ')', ColorEnd);
|
writeln(COLOR_RED, COLOR_BOLD, '(', fmsg, ')', COLOR_END);
|
||||||
++nfailed;
|
++nfailed;
|
||||||
} else {
|
} else {
|
||||||
writeln(ColorGreen, ColorBold, "(success)", ColorEnd);
|
writeln(COLOR_GREEN, COLOR_BOLD, "(success)", COLOR_END);
|
||||||
++nsuccess;
|
++nsuccess;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DirectoryStream ds(testdir);
|
directory_stream ds{testdir};
|
||||||
for (auto v: iter(ds)) {
|
for (auto v: iter(ds)) {
|
||||||
if ((v.type() != FileType::regular) || (v.extension() != srcext))
|
if ((v.type() != file_type::REGULAR) || (v.extension() != srcext))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
modname = v.stem();
|
modname = v.stem();
|
||||||
|
|
||||||
String exepath = testdir;
|
std::string exepath = testdir;
|
||||||
exepath += PathSeparator;
|
exepath += PATH_SEPARATOR;
|
||||||
exepath += modname;
|
exepath += modname;
|
||||||
#ifdef OSTD_PLATFORM_WIN32
|
#ifdef OSTD_PLATFORM_WIN32
|
||||||
exepath += ".exe";
|
exepath += ".exe";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto cxxcmd = appender<String>();
|
auto cxxcmd = appender<std::string>();
|
||||||
format(cxxcmd, "%s %s%s%s -o %s %s", compiler, testdir, PathSeparator,
|
format(cxxcmd, "%s %s%s%s -o %s %s", compiler, testdir, PATH_SEPARATOR,
|
||||||
v.filename(), exepath, cxxflags);
|
v.filename(), exepath, cxxflags);
|
||||||
if (!userflags.empty()) {
|
if (!userflags.empty()) {
|
||||||
cxxcmd.get() += ' ';
|
cxxcmd.get() += ' ';
|
||||||
|
@ -85,7 +85,7 @@ int main() {
|
||||||
print_result();
|
print_result();
|
||||||
}
|
}
|
||||||
|
|
||||||
writeln("\n", ColorBlue, ColorBold, "testing done:", ColorEnd);
|
writeln("\n", COLOR_BLUE, COLOR_BOLD, "testing done:", COLOR_END);
|
||||||
writeln(ColorGreen, "SUCCESS: ", nsuccess, ColorEnd);
|
writeln(COLOR_GREEN, "SUCCESS: ", nsuccess, COLOR_END);
|
||||||
writeln(ColorRed, "FAILURE: ", nfailed, ColorEnd);
|
writeln(COLOR_RED, "FAILURE: ", nfailed, COLOR_END);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue