Commit 2cd6d686 by Vicent Marti

Tests now run with the resources folder as a hardcoded path

Each tests expects a "TEST_RESOURCES" define with the full path to the
resources folder.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
parent 6c14d641
...@@ -5,9 +5,6 @@ ...@@ -5,9 +5,6 @@
#include <git2/odb.h> #include <git2/odb.h>
#include <git2/index.h> #include <git2/index.h>
#define TEST_INDEX_PATH "../resources/testrepo.git/index"
#define TEST_INDEX2_PATH "../resources/gitgit.index"
#define TEST_INDEX_ENTRY_COUNT 109 #define TEST_INDEX_ENTRY_COUNT 109
#define TEST_INDEX2_ENTRY_COUNT 1437 #define TEST_INDEX2_ENTRY_COUNT 1437
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#include <git2/odb.h> #include <git2/odb.h>
#include <git2/index.h> #include <git2/index.h>
#define TEST_INDEX_PATH "../resources/testrepo.git/index"
int filecmp(const char *filename1, const char *filename2) int filecmp(const char *filename1, const char *filename2)
{ {
git_file file1, file2; git_file file1, file2;
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#include <git2/odb.h> #include <git2/odb.h>
#include <git2/index.h> #include <git2/index.h>
#define TEST_INDEX_PATH "../t0600-objects/index"
/* /*
void print_entries(git_index *index) void print_entries(git_index *index)
{ {
......
...@@ -29,8 +29,10 @@ ...@@ -29,8 +29,10 @@
#include "test_lib.h" #include "test_lib.h"
#include <git2.h> #include <git2.h>
#define ODB_FOLDER "../resources/testrepo.git/objects/" #define ODB_FOLDER (TEST_RESOURCES "/testrepo.git/objects/")
#define REPOSITORY_FOLDER "../resources/testrepo.git/" #define REPOSITORY_FOLDER (TEST_RESOURCES "/testrepo.git/")
#define TEST_INDEX_PATH (TEST_RESOURCES "/testrepo.git/index")
#define TEST_INDEX2_PATH (TEST_RESOURCES "/gitgit.index")
typedef struct object_data { typedef struct object_data {
unsigned char *bytes; /* (compressed) bytes stored in object store */ unsigned char *bytes; /* (compressed) bytes stored in object store */
......
...@@ -144,6 +144,7 @@ def build_tests(bld): ...@@ -144,6 +144,7 @@ def build_tests(bld):
return return
directory = bld.path directory = bld.path
resources_path = directory.find_node('tests/resources/').abspath()
# Common object with the Test library methods # Common object with the Test library methods
bld.objects(source=['tests/test_helpers.c', 'tests/test_lib.c'], includes=['src', 'tests'], target='test_helper') bld.objects(source=['tests/test_helpers.c', 'tests/test_lib.c'], includes=['src', 'tests'], target='test_helper')
...@@ -164,7 +165,7 @@ def build_tests(bld): ...@@ -164,7 +165,7 @@ def build_tests(bld):
source=[test_file, 'tests/test_main.c'], source=[test_file, 'tests/test_main.c'],
target=test_name, target=test_name,
includes=['src', 'tests'], includes=['src', 'tests'],
defines=['TEST_TOC="%s.toc"' % test_name], defines=['TEST_TOC="%s.toc"' % test_name, 'TEST_RESOURCES="%s"' % resources_path],
install_path=None, install_path=None,
stlib=['git2'], # link with the git2 static lib we've just compiled' stlib=['git2'], # link with the git2 static lib we've just compiled'
stlibpath=[directory.find_node('build/tests/').abspath(), directory.abspath()], stlibpath=[directory.find_node('build/tests/').abspath(), directory.abspath()],
...@@ -200,22 +201,21 @@ class _run_tests(Context): ...@@ -200,22 +201,21 @@ class _run_tests(Context):
fun = 'run_tests' fun = 'run_tests'
def run_tests(ctx): def run_tests(ctx):
import shutil, sys import shutil, tempfile, sys
failed = False failed = False
test_folder = ctx.path.make_node('tests/tmp/') test_folder = tempfile.mkdtemp()
test_folder.mkdir()
test_glob = 'build/tests/t????-*' test_glob = 'build/tests/t????-*'
if sys.platform == 'win32': if sys.platform == 'win32':
test_glob = 'build/tests/t????-*.exe' test_glob += '.exe'
for test in ctx.path.ant_glob(test_glob): for test in ctx.path.ant_glob(test_glob):
if ctx.exec_command(test.abspath(), cwd=test_folder.abspath()) != 0: if ctx.exec_command(test.abspath(), cwd=test_folder) != 0:
failed = True failed = True
break break
shutil.rmtree(test_folder.abspath()) shutil.rmtree(test_folder)
if failed: if failed:
ctx.fatal('Test run failed') ctx.fatal('Test run failed')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment