diff options
author | Claudius Holeksa <mail@keldu.de> | 2023-06-10 17:21:29 +0200 |
---|---|---|
committer | Claudius Holeksa <mail@keldu.de> | 2023-06-10 17:21:29 +0200 |
commit | 6c8e3d1786a5de4ae562c03693b8dad9dd0ab26e (patch) | |
tree | 18275240cfb8ff30e1d383ea351a277e894e988f /tests | |
parent | b670001ca80dbc0e1a51b4a08776eb41dabc2a9e (diff) |
tests,c++: Intermediate commit preparing testing and json
Diffstat (limited to 'tests')
-rw-r--r-- | tests/.nix/derivation.nix | 27 | ||||
-rw-r--r-- | tests/SConscript | 32 | ||||
-rw-r--r-- | tests/SConstruct | 66 | ||||
-rw-r--r-- | tests/core.cpp | 7 |
4 files changed, 132 insertions, 0 deletions
diff --git a/tests/.nix/derivation.nix b/tests/.nix/derivation.nix new file mode 100644 index 0000000..d5a698c --- /dev/null +++ b/tests/.nix/derivation.nix @@ -0,0 +1,27 @@ +{ lib +, stdenvNoCC +, scons +, clang +, clang-tools +, version +, forstio +}: + +stdenvNoCC.mkDerivation { + pname = "forstio-test-cases"; + inherit version; + src = ./..; + + enableParallelBuilding = true; + + nativeBuildInputs = [ + scons + clang + clang-tools + forstio.core + forstio.async + forstio.test + ]; + + outputs = ["out" "dev"]; +} diff --git a/tests/SConscript b/tests/SConscript new file mode 100644 index 0000000..3659c0b --- /dev/null +++ b/tests/SConscript @@ -0,0 +1,32 @@ +#!/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); + +# Set Alias +env.Alias('test', test_cases_env.program); +env.Alias('check', test_cases_env.program); + +env.targets += ['test']; + +# Install +env.Install('$prefix/bin/', [test_cases_env.program]); diff --git a/tests/SConstruct b/tests/SConstruct new file mode 100644 index 0000000..98eccdb --- /dev/null +++ b/tests/SConstruct @@ -0,0 +1,66 @@ +#!/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', 'forstio-async']) +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') diff --git a/tests/core.cpp b/tests/core.cpp new file mode 100644 index 0000000..af19b42 --- /dev/null +++ b/tests/core.cpp @@ -0,0 +1,7 @@ +#include <forstio/test/suite.h> + +namespace { +SAW_TEST { + +} +} |