From: Tilman Sauerbeck Date: Wed, 8 Jan 2020 16:40:32 +0000 (+0100) Subject: build: Add infrastructure for building automated tests. X-Git-Url: http://git.code-monkey.de/?a=commitdiff_plain;h=22de17136c8c5692e83d5d15ce09528d9afd3e13;p=gps-watch.git build: Add infrastructure for building automated tests. --- diff --git a/.gitignore b/.gitignore index fe83278..a160177 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .sconsign.dblite build-target +build-test diff --git a/SConscript.test b/SConscript.test new file mode 100644 index 0000000..28ddfd7 --- /dev/null +++ b/SConscript.test @@ -0,0 +1,29 @@ +Import('env') +env = env.Clone() + +env.Append(RUSTCFLAGS = [ + '-g', + '-C', 'opt-level=s', +]) + +SConscript('SConscript.libcommon.rs', exports='env', duplicate=0) + +test_source_files = [ + 'test/main.rs', # Must be listed first (see below). +] + +test_env = env.Clone() + +test_env.Append(RUSTCFLAGS = [ + '-L', '$LIBPATH', + '--test', +]) + +test = test_env.Rustc('gps-watch-test', test_source_files[0]) + +for f in test_source_files: + Depends(test, f) + +Depends(test, 'libcommon.rlib') + +Default(test) diff --git a/SConstruct b/SConstruct index 7f486b2..4b5a1bc 100644 --- a/SConstruct +++ b/SConstruct @@ -36,3 +36,8 @@ env = root_env.Clone() env['variant_dir'] = 'build-target' env['LIBPATH'] = env['variant_dir'] SConscript('SConscript.target', exports='env', variant_dir=env['variant_dir'], duplicate=0) + +env = root_env.Clone() +env['variant_dir'] = 'build-test' +env['LIBPATH'] = env['variant_dir'] +SConscript('SConscript.test', exports='env', variant_dir=env['variant_dir'], duplicate=0) diff --git a/test/main.rs b/test/main.rs new file mode 100644 index 0000000..0e0c124 --- /dev/null +++ b/test/main.rs @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2020 Tilman Sauerbeck (tilman at code-monkey de) + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +extern crate common;