Compare commits
No commits in common. "52bf0f22f0f36a83a4b8b20c4b727db63f1b0dce" and "a88aa739b19b5a396c23a366ecaa12aff17a3b61" have entirely different histories.
52bf0f22f0
...
a88aa739b1
7 changed files with 44 additions and 156 deletions
44
.drone.yml
44
.drone.yml
|
@ -32,41 +32,8 @@ steps:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit ${has_fomatting_issues}
|
exit ${has_fomatting_issues}
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: unit tests
|
|
||||||
clone:
|
|
||||||
recursive: true
|
|
||||||
submodule_update_remote: true
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
branch:
|
|
||||||
- main
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: unit tests
|
|
||||||
image: unit_tests:latest
|
|
||||||
pull: if-not-exists
|
|
||||||
commands:
|
|
||||||
- |
|
|
||||||
set -e
|
|
||||||
|
|
||||||
git submodule update --init --recursive
|
|
||||||
conan build . \
|
|
||||||
-c tools.system.package_manager:mode=install \
|
|
||||||
-s build_type=Release \
|
|
||||||
-o enable_static_analysis=False \
|
|
||||||
-o enable_tests=True \
|
|
||||||
--build=missing
|
|
||||||
|
|
||||||
for test in $(find ./build -type f -name '*_tests' -executable); do
|
|
||||||
echo "Running $test"
|
|
||||||
"$test"
|
|
||||||
done
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: static analysis
|
name: static analysis
|
||||||
|
@ -84,12 +51,5 @@ steps:
|
||||||
pull: if-not-exists
|
pull: if-not-exists
|
||||||
privileged: true
|
privileged: true
|
||||||
commands:
|
commands:
|
||||||
- |
|
- git submodule update --init --recursive
|
||||||
git submodule update --init --recursive
|
- conan build . -s build_type=Release -o enable_static_analysis=True --build=missing
|
||||||
|
|
||||||
conan build . \
|
|
||||||
-c tools.system.package_manager:mode=install \
|
|
||||||
-s build_type=Release \
|
|
||||||
-o enable_static_analysis=True \
|
|
||||||
-o enable_tests=True \
|
|
||||||
--build=missing
|
|
||||||
|
|
|
@ -2,10 +2,8 @@
|
||||||
|
|
||||||
namespace lt {
|
namespace lt {
|
||||||
|
|
||||||
std::mt19937_64 UUID::s_engine = std::mt19937_64(std::random_device()());
|
auto UUID::s_engine = std::mt19937_64(std::random_device()());
|
||||||
|
auto UUID::s_distribution = std::uniform_int_distribution<uint64_t> {};
|
||||||
std::uniform_int_distribution<uint64_t>
|
|
||||||
UUID::s_distribution = std::uniform_int_distribution<uint64_t> {};
|
|
||||||
|
|
||||||
UUID::UUID(uint64_t uuid /* = -1 */): m_uuid(uuid == -1 ? s_distribution(s_engine) : uuid)
|
UUID::UUID(uint64_t uuid /* = -1 */): m_uuid(uuid == -1 ? s_distribution(s_engine) : uuid)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,62 +26,6 @@ concept test = requires(T test) {
|
||||||
} // namespace concepts
|
} // namespace concepts
|
||||||
|
|
||||||
|
|
||||||
namespace details {
|
|
||||||
|
|
||||||
|
|
||||||
class Registry
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using Suite = void (*)();
|
|
||||||
|
|
||||||
static void register_suite(Suite suite)
|
|
||||||
{
|
|
||||||
instance().m_suites.emplace_back(suite);
|
|
||||||
}
|
|
||||||
|
|
||||||
static auto run_all() -> int32_t
|
|
||||||
{
|
|
||||||
for (auto &test : instance().m_suites)
|
|
||||||
{
|
|
||||||
test();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "_________________________[TEST RESULTS]_________________________\n";
|
|
||||||
std::cout << "Ran " << instance().m_failed_count + instance().m_pasesed_count << " tests:\n"
|
|
||||||
<< "\tpassed: " << instance().m_pasesed_count << '\n'
|
|
||||||
<< "\tfailed: " << instance().m_failed_count << '\n';
|
|
||||||
|
|
||||||
return instance().m_failed_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void increment_passed_count()
|
|
||||||
{
|
|
||||||
++instance().m_pasesed_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void increment_failed_count()
|
|
||||||
{
|
|
||||||
++instance().m_failed_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Registry() = default;
|
|
||||||
|
|
||||||
[[nodiscard]] static auto instance() -> Registry &
|
|
||||||
{
|
|
||||||
static auto registry = Registry {};
|
|
||||||
return registry;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<void (*)()> m_suites;
|
|
||||||
|
|
||||||
int32_t m_pasesed_count {};
|
|
||||||
int32_t m_failed_count {};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace details
|
|
||||||
|
|
||||||
struct Case
|
struct Case
|
||||||
{
|
{
|
||||||
auto operator=(std::invocable auto test) -> void // NOLINT
|
auto operator=(std::invocable auto test) -> void // NOLINT
|
||||||
|
@ -96,17 +40,51 @@ struct Case
|
||||||
{
|
{
|
||||||
std::cout << " --> FAIL !" << '\n';
|
std::cout << " --> FAIL !" << '\n';
|
||||||
std::cout << exp.what() << "\n\n";
|
std::cout << exp.what() << "\n\n";
|
||||||
details::Registry::increment_failed_count();
|
|
||||||
return; // TODO(Light): Should we run the remaining tests after a failure?
|
return; // TODO(Light): Should we run the remaining tests after a failure?
|
||||||
}
|
}
|
||||||
|
|
||||||
details::Registry::increment_passed_count();
|
|
||||||
std::cout << " --> SUCCESS :D" << "\n";
|
std::cout << " --> SUCCESS :D" << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string_view name;
|
std::string_view name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace details {
|
||||||
|
|
||||||
|
|
||||||
|
class Registry
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using Suite = void (*)();
|
||||||
|
|
||||||
|
static void register_suite(Suite suite)
|
||||||
|
{
|
||||||
|
instance().m_suites.emplace_back(suite);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void run_all()
|
||||||
|
{
|
||||||
|
for (auto &test : instance().m_suites)
|
||||||
|
{
|
||||||
|
test();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Registry() = default;
|
||||||
|
|
||||||
|
[[nodiscard]] static auto instance() -> Registry &
|
||||||
|
{
|
||||||
|
static auto registry = Registry {};
|
||||||
|
return registry;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<void (*)()> m_suites;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace details
|
||||||
|
|
||||||
struct TestSuite
|
struct TestSuite
|
||||||
{
|
{
|
||||||
template<class TSuite>
|
template<class TSuite>
|
||||||
|
|
|
@ -6,7 +6,7 @@ try
|
||||||
using namespace ::lt::test;
|
using namespace ::lt::test;
|
||||||
using namespace ::lt::test::details;
|
using namespace ::lt::test::details;
|
||||||
|
|
||||||
return Registry::run_all();
|
Registry::run_all();
|
||||||
}
|
}
|
||||||
catch (const std::exception &exp)
|
catch (const std::exception &exp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
lt::test::Suite meta = []() {
|
lt::test::Suite meta = []() {
|
||||||
using lt::test::expect_eq;
|
using lt::test::expect_eq;
|
||||||
using lt::test::expect_true;
|
|
||||||
|
|
||||||
lt::test::Case { "test_1" } = [] {
|
lt::test::Case { "test_1" } = [] {
|
||||||
expect_eq(5, 5);
|
expect_eq(5, 5);
|
||||||
|
@ -13,18 +12,7 @@ lt::test::Suite meta = []() {
|
||||||
};
|
};
|
||||||
|
|
||||||
lt::test::Case { "test_3" } = [] {
|
lt::test::Case { "test_3" } = [] {
|
||||||
auto exception_thrown = false;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
expect_eq(true, false);
|
expect_eq(true, false);
|
||||||
}
|
|
||||||
catch (const std::exception &exp)
|
|
||||||
{
|
|
||||||
exception_thrown = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
expect_true(exception_thrown);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
lt::test::Case { "test_4" } = [] {
|
lt::test::Case { "test_4" } = [] {
|
||||||
|
@ -32,5 +20,6 @@ lt::test::Suite meta = []() {
|
||||||
};
|
};
|
||||||
|
|
||||||
lt::test::Case { "test_5" } = [] {
|
lt::test::Case { "test_5" } = [] {
|
||||||
|
throw std::runtime_error("Uncaught std exception!");
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,7 +55,7 @@ void lWindow::on_event(const Event &event)
|
||||||
on_window_resize(dynamic_cast<const WindowResizedEvent &>(event));
|
on_window_resize(dynamic_cast<const WindowResizedEvent &>(event));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
FROM alpine:latest
|
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
|
||||||
bash \
|
|
||||||
clang \
|
|
||||||
llvm \
|
|
||||||
cmake \
|
|
||||||
git \
|
|
||||||
make \
|
|
||||||
g++ \
|
|
||||||
python3 \
|
|
||||||
py3-pip \
|
|
||||||
mesa-dev \
|
|
||||||
mesa-gl \
|
|
||||||
pkgconf
|
|
||||||
|
|
||||||
|
|
||||||
RUN pip install --no-cache-dir --break-system-packages conan gitpython \
|
|
||||||
&& conan profile detect
|
|
||||||
|
|
||||||
RUN clang --version \
|
|
||||||
&& conan --version \
|
|
||||||
&& pip --version \
|
|
||||||
&& cmake --version \
|
|
||||||
&& clang --version
|
|
||||||
|
|
||||||
|
|
||||||
RUN git clone 'https://git.light7734.com/light7734/light.git' --recursive \
|
|
||||||
&& cd light \
|
|
||||||
&& conan install . \
|
|
||||||
-s build_type=Debug \
|
|
||||||
-c tools.system.package_manager:mode=install \
|
|
||||||
--build=missing \
|
|
||||||
&& conan install . \
|
|
||||||
-s build_type=Release \
|
|
||||||
-c tools.system.package_manager:mode=install \
|
|
||||||
--build=missing
|
|
Loading…
Add table
Reference in a new issue