summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2023-12-04 13:45:37 +0100
committerClaudius "keldu" Holeksa <mail@keldu.de>2023-12-04 13:45:37 +0100
commit8da0229a7e172a86c023edc6bb25ba803c68f5d3 (patch)
treec305cf094528b70ae99af79a9a650f9dc98fc0b9
parentfb7ed24d557c9f9ac5eaa60dbf22cba509953c1a (diff)
core, tests: Moving core tests to core module
-rw-r--r--default.nix7
-rw-r--r--modules/core/.nix/derivation.nix6
-rw-r--r--modules/core/SConstruct4
-rw-r--r--modules/core/c++/SConscript8
-rw-r--r--modules/core/c++/test/SConscript (renamed from modules/test/SConscript)6
-rw-r--r--modules/core/c++/test/suite.cpp (renamed from modules/test/suite.cpp)0
-rw-r--r--modules/core/c++/test/suite.h (renamed from modules/test/suite.h)2
-rw-r--r--modules/core/tests/SConscript29
-rw-r--r--modules/core/tests/core.cpp (renamed from tests/core.cpp)8
-rw-r--r--modules/core/tests/tree.cpp (renamed from tests/tree.cpp)4
-rw-r--r--modules/test/.nix/derivation.nix28
-rw-r--r--modules/test/SConstruct66
12 files changed, 53 insertions, 115 deletions
diff --git a/default.nix b/default.nix
index f6e4913..4d2e1b0 100644
--- a/default.nix
+++ b/default.nix
@@ -13,13 +13,6 @@ in rec {
inherit clang-tools;
};
- test = pkgs.callPackage modules/test/.nix/derivation.nix {
- inherit version;
- inherit forstio;
- inherit stdenv;
- inherit clang-tools;
- };
-
async = pkgs.callPackage modules/async/.nix/derivation.nix {
inherit version;
inherit forstio;
diff --git a/modules/core/.nix/derivation.nix b/modules/core/.nix/derivation.nix
index 1618651..372d3a6 100644
--- a/modules/core/.nix/derivation.nix
+++ b/modules/core/.nix/derivation.nix
@@ -17,5 +17,11 @@ stdenv.mkDerivation {
clang-tools
];
+ doCheck = true;
+ checkPhase = ''
+ scons test
+ ./bin/tests
+ '';
+
outputs = ["out" "dev"];
}
diff --git a/modules/core/SConstruct b/modules/core/SConstruct
index 015645b..643550d 100644
--- a/modules/core/SConstruct
+++ b/modules/core/SConstruct
@@ -58,7 +58,11 @@ env.targets = [];
Export('env')
SConscript('c++/SConscript')
+SConscript('c++/test/SConscript')
+SConscript('tests/SConscript')
+
+# Aliasing
env.Alias('cdb', env.cdb);
env.Alias('all', [env.targets]);
env.Default('all');
diff --git a/modules/core/c++/SConscript b/modules/core/c++/SConscript
index 02bd050..cea6b76 100644
--- a/modules/core/c++/SConscript
+++ b/modules/core/c++/SConscript
@@ -21,20 +21,20 @@ env.headers += core_env.headers;
## Shared lib
objects_shared = []
core_env.add_source_files(objects_shared, core_env.sources, shared=True);
-core_env.library_shared = core_env.SharedLibrary('#build/forstio-core', [objects_shared]);
+env.library_shared = core_env.SharedLibrary('#build/forstio-core', [objects_shared]);
## Static lib
objects_static = []
core_env.add_source_files(objects_static, core_env.sources, shared=False);
-core_env.library_static = core_env.StaticLibrary('#build/forstio-core', [objects_static]);
+env.library_static = core_env.StaticLibrary('#build/forstio-core', [objects_static]);
# Set Alias
-env.Alias('library_core', [core_env.library_shared, core_env.library_static]);
+env.Alias('library_core', [env.library_shared, env.library_static]);
env.targets += ['library_core'];
# Install
-env.Install('$prefix/lib/', [core_env.library_shared, core_env.library_static]);
+env.Install('$prefix/lib/', [env.library_shared, env.library_static]);
env.Install('$prefix/include/forstio/core/', [core_env.headers]);
# Test
diff --git a/modules/test/SConscript b/modules/core/c++/test/SConscript
index 6379b24..1c4de76 100644
--- a/modules/test/SConscript
+++ b/modules/core/c++/test/SConscript
@@ -21,13 +21,13 @@ env.headers += test_env.headers;
## Shared lib
objects = []
test_env.add_source_files(objects, test_env.sources, shared=False);
-test_env.library = test_env.StaticLibrary('#build/forstio-test', [objects]);
+env.test_library = test_env.StaticLibrary('#build/forstio-test', [objects]);
# Set Alias
-env.Alias('library_test', [test_env.library]);
+env.Alias('library_test', [env.test_library]);
env.targets += ['library_test'];
# Install
-env.Install('$prefix/lib/', [test_env.library]);
+env.Install('$prefix/lib/', [env.test_library]);
env.Install('$prefix/include/forstio/test/', [test_env.headers]);
diff --git a/modules/test/suite.cpp b/modules/core/c++/test/suite.cpp
index 0fca8f9..0fca8f9 100644
--- a/modules/test/suite.cpp
+++ b/modules/core/c++/test/suite.cpp
diff --git a/modules/test/suite.h b/modules/core/c++/test/suite.h
index 34f29bf..e28a94c 100644
--- a/modules/test/suite.h
+++ b/modules/core/c++/test/suite.h
@@ -5,7 +5,7 @@
#include <stdexcept>
#include <type_traits>
-#include <forstio/core/common.h>
+#include "../common.h"
namespace saw {
namespace test {
diff --git a/modules/core/tests/SConscript b/modules/core/tests/SConscript
new file mode 100644
index 0000000..cec3132
--- /dev/null
+++ b/modules/core/tests/SConscript
@@ -0,0 +1,29 @@
+#!/bin/false
+
+import os
+import os.path
+import glob
+
+
+Import('env')
+
+dir_path = Dir('.').abspath
+
+# Environment for base library
+test_cases_env = env.Clone();
+
+test_cases_env.sources = sorted(glob.glob(dir_path + "/*.cpp"))
+test_cases_env.headers = sorted(glob.glob(dir_path + "/*.h"))
+
+env.sources += test_cases_env.sources;
+env.headers += test_cases_env.headers;
+
+objects_static = []
+test_cases_env.add_source_files(objects_static, test_cases_env.sources, shared=False);
+test_cases_env.program = test_cases_env.Program('#bin/tests', [objects_static, env.library_static, env.test_library]);
+
+# Set Alias
+env.Alias('test', test_cases_env.program);
+env.Alias('check', test_cases_env.program);
+
+env.targets += ['test','check'];
diff --git a/tests/core.cpp b/modules/core/tests/core.cpp
index 281cca6..2b63b94 100644
--- a/tests/core.cpp
+++ b/modules/core/tests/core.cpp
@@ -1,7 +1,7 @@
-#include <forstio/test/suite.h>
-#include <forstio/core/id.h>
-#include <forstio/core/id_map.h>
-#include <forstio/core/string_literal.h>
+#include "../c++/test/suite.h"
+#include "../c++/id.h"
+#include "../c++/id_map.h"
+#include "../c++/string_literal.h"
namespace {
SAW_TEST("ID functionality") {
diff --git a/tests/tree.cpp b/modules/core/tests/tree.cpp
index 2515ee9..78f72ef 100644
--- a/tests/tree.cpp
+++ b/modules/core/tests/tree.cpp
@@ -1,5 +1,5 @@
-#include <forstio/test/suite.h>
-#include <forstio/core/tree.h>
+#include "../c++/test/suite.h"
+#include "../c++/tree.h"
namespace {
SAW_TEST("Tree add child"){
diff --git a/modules/test/.nix/derivation.nix b/modules/test/.nix/derivation.nix
deleted file mode 100644
index c15421d..0000000
--- a/modules/test/.nix/derivation.nix
+++ /dev/null
@@ -1,28 +0,0 @@
-{ lib
-, stdenv
-, scons
-, clang-tools
-, version
-, forstio
-}:
-
-let
-
-in stdenv.mkDerivation {
- pname = "forstio-test";
- inherit version;
- src = ./..;
-
- enableParallelBuilding = true;
-
- nativeBuildInputs = [
- scons
- clang-tools
- ];
-
- buildInputs = [
- forstio.core
- ];
-
- outputs = ["out" "dev"];
-}
diff --git a/modules/test/SConstruct b/modules/test/SConstruct
deleted file mode 100644
index 0d7b7c6..0000000
--- a/modules/test/SConstruct
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/env python3
-
-import sys
-import os
-import os.path
-import glob
-import re
-
-
-if sys.version_info < (3,):
- def isbasestring(s):
- return isinstance(s,basestring)
-else:
- def isbasestring(s):
- return isinstance(s, (str,bytes))
-
-def add_kel_source_files(self, sources, filetype, lib_env=None, shared=False, target_post=""):
-
- if isbasestring(filetype):
- dir_path = self.Dir('.').abspath
- filetype = sorted(glob.glob(dir_path+"/"+filetype))
-
- for path in filetype:
- target_name = re.sub( r'(.*?)(\.cpp|\.c\+\+)', r'\1' + target_post, path )
- if shared:
- target_name+='.os'
- sources.append( self.SharedObject( target=target_name, source=path ) )
- else:
- target_name+='.o'
- sources.append( self.StaticObject( target=target_name, source=path ) )
- pass
-
-def isAbsolutePath(key, dirname, env):
- assert os.path.isabs(dirname), "%r must have absolute path syntax" % (key,)
-
-env_vars = Variables(
- args=ARGUMENTS
-)
-
-env_vars.Add('prefix',
- help='Installation target location of build results and headers',
- default='/usr/local/',
- validator=isAbsolutePath
-)
-
-env=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[],
- CPPDEFINES=['SAW_UNIX'],
- CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'],
- LIBS=['forstio-core'])
-env.__class__.add_source_files = add_kel_source_files
-env.Tool('compilation_db');
-env.cdb = env.CompilationDatabase('compile_commands.json');
-
-env.objects = [];
-env.sources = [];
-env.headers = [];
-env.targets = [];
-
-Export('env')
-SConscript('SConscript')
-
-env.Alias('cdb', env.cdb);
-env.Alias('all', [env.targets]);
-env.Default('all');
-
-env.Alias('install', '$prefix')