aboutsummaryrefslogtreecommitdiff
path: root/tests/SCsub
diff options
context:
space:
mode:
author Spartan322 <Megacake1234@gmail.com>2024-06-15 15:40:31 +0200
committer Spartan322 <Megacake1234@gmail.com>2024-06-22 13:57:49 +0200
commit1a694a8b26a441b12547057d6e0be61a111cced3 (patch)
tree51ca6d5948e92be37b9ee6674cb96801d2cd03f8 /tests/SCsub
parent8b623bf4087aa360842ad31145d4ab6946cee9aa (diff)
Add unit testsadd/unit-testing
Make github action tests run explicit Fix dropping annotation list for Errors Fix potential empty get_errors crashes Fix incorrect csv error behavior Add use_sep for `LineObject` and `std::vector<LineObject>` Remove constexpr of load_from_buffer and load_from_string for parsers Add snitch-org/snitch@d6632123cc8d13bdbc5cd60fd6741b9e0f635e82 Make versioned submodules ignore dirty Add tests/bin/* to gitignore
Diffstat (limited to 'tests/SCsub')
-rw-r--r--tests/SCsub55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/SCsub b/tests/SCsub
new file mode 100644
index 0000000..0a18777
--- /dev/null
+++ b/tests/SCsub
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+import os
+import subprocess
+import platform
+import sys
+
+import SCons
+from SCons.Script.SConscript import SConsEnvironment
+
+
+def UnitTestPostAction(target=None, source=None, env=None):
+ print()
+ return subprocess.run([target[0].path]).returncode
+
+def UnitTest(env, **kwargs):
+ test = env.Program(**kwargs)
+ unit_test_action = env.Action(UnitTestPostAction, None)
+ test_post_action = env.AddPostAction(test, unit_test_action)
+ env.NoCache(test)
+ env.AlwaysBuild(test_post_action)
+ return test
+
+SConsEnvironment.UnitTest = UnitTest
+
+Import("env")
+
+BINDIR = "bin"
+
+env.openvic_dataloader_tests = {}
+
+# For the reference:
+# - CCFLAGS are compilation flags shared between C and C++
+# - CFLAGS are for C-specific compilation flags
+# - CXXFLAGS are for C++-specific compilation flags
+# - CPPFLAGS are for pre-processor flags
+# - CPPDEFINES are for pre-processor defines
+# - LINKFLAGS are for linking flags
+
+# tweak this if you want to use different folders, or more folders, to store your source code in.
+source_path = "src"
+
+tests_name = "openvic-dataloader"
+tests_env = env.Clone()
+tests_env.Append(CPPDEFINES=["OPENVIC_DATALOADER_TESTS"])
+tests_env.Append(CPPPATH=[tests_env.Dir(source_path)])
+tests_env.tests_sources = env.GlobRecursive("*.cpp", [source_path])
+
+SConscript("deps/SCsub", {"env": tests_env })
+
+tests_program = tests_env.UnitTest(
+ source=tests_env.tests_sources,
+ target=os.path.join(BINDIR, tests_name),
+ PROGSUFFIX=".tests" + env["PROGSUFFIX"]
+)
+Default(tests_program) \ No newline at end of file