From 09925e59074a78b7b30af0be973e9abae11d2cde Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 15 Jun 2020 10:33:54 -0700 Subject: Fix test for compilation_db to work on windows and linux --- test/CompilationDatabase/basic.py | 25 +++++++++++++++---------- test/CompilationDatabase/fixture/SConstruct | 1 + 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/test/CompilationDatabase/basic.py b/test/CompilationDatabase/basic.py index 21c883b..2f76752 100644 --- a/test/CompilationDatabase/basic.py +++ b/test/CompilationDatabase/basic.py @@ -27,15 +27,13 @@ and values of COMPILATIONDB_USE_ABSPATH """ import sys +import os +import os.path import TestSCons test = TestSCons.TestSCons() -if sys.platform == 'win32': - test.file_fixture('mylink_win32.py', 'mylink.py') -else: - test.file_fixture('mylink.py') - +test.file_fixture('mylink.py') test.file_fixture('mygcc.py') test.verbose_set(1) @@ -67,23 +65,30 @@ example_rel_file = """[ } ]""" % (sys.executable, test.workdir) +if sys.platform == 'win32': + example_rel_file = example_rel_file.replace('\\', '\\\\') + for f in rel_files: # print("Checking:%s" % f) test.must_exist(f) - test.must_match(f, example_rel_file) + test.must_match(f, example_rel_file, mode='r') example_abs_file = """[ { "command": "%s mygcc.py cc -o test_main.o -c test_main.c", "directory": "%s", - "file": "%s/test_main.c", - "output": "%s/test_main.o" + "file": "%s", + "output": "%s" } -]""" % (sys.executable, test.workdir, test.workdir, test.workdir) +]""" % (sys.executable, test.workdir, os.path.join(test.workdir, 'test_main.c'), os.path.join(test.workdir, 'test_main.o')) + +if sys.platform == 'win32': + example_abs_file = example_abs_file.replace('\\', '\\\\') + for f in abs_files: test.must_exist(f) - test.must_match(f, example_abs_file) + test.must_match(f, example_abs_file, mode='r') test.pass_test() diff --git a/test/CompilationDatabase/fixture/SConstruct b/test/CompilationDatabase/fixture/SConstruct index 4043b5a..ea23bc3 100644 --- a/test/CompilationDatabase/fixture/SConstruct +++ b/test/CompilationDatabase/fixture/SConstruct @@ -7,6 +7,7 @@ env = Environment( LINKFLAGS=[], CC='$PYTHON mygcc.py cc', CXX='$PYTHON mygcc.py c++', + tools=['gcc','g++','gnulink'], ) env.Tool('compilation_db') -- cgit v0.12