From 5813144246f8f132f90bea117e578477914be0ea Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Wed, 13 Nov 2013 22:10:42 +0200 Subject: [PATCH] Make tests build in a separate folder, add to gitignore --- .gitignore | 19 ++++++++++++------- tests/SConstruct | 9 +++++++-- tests/alltypes/SConscript | 6 +++--- tests/backwards_compatibility/SConscript | 4 ++-- tests/basic_buffer/SConscript | 6 +++--- tests/basic_stream/SConscript | 6 +++--- tests/buffer_only/SConscript | 8 ++++---- tests/callbacks/SConscript | 4 ++-- tests/cxx_main_program/SConscript | 8 ++++---- tests/decode_unittests/SConscript | 2 +- tests/encode_unittests/SConscript | 2 +- tests/extensions/SConscript | 10 +++++----- tests/extra_fields/SConscript | 6 +++--- tests/field_size_16/SConscript | 6 +++--- tests/field_size_32/SConscript | 6 +++--- tests/missing_fields/SConscript | 2 +- tests/no_errmsg/SConscript | 8 ++++---- 17 files changed, 61 insertions(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index b83afef..70f80a6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,17 +5,22 @@ *.pb.c *.pb.h *.pb +*.pyc *~ *.tar.gz .sconsign.dblite +config.log +.sconf_temp +tests/build julkaisu.txt docs/*.html docs/generator_flow.png -example/client -example/server -example_avr_double/decode_double -example_avr_double/encode_double -example_avr_double/test_conversions -example_unions/decode -example_unions/encode +examples/simple/simple +examples/network_server/client +examples/network_server/server +examples/using_double_on_avr/decode_double +examples/using_double_on_avr/encode_double +examples/using_double_on_avr/test_conversions +examples/using_union_messages/decode +examples/using_union_messages/encode generator/nanopb_pb2.pyc diff --git a/tests/SConstruct b/tests/SConstruct index 100fb54..675989a 100644 --- a/tests/SConstruct +++ b/tests/SConstruct @@ -26,7 +26,7 @@ if 'CXXFLAGS' in ARGUMENTS: env.Append(CCFLAGS = ARGUMENTS['CXXFLAGS']) add_nanopb_builders(env) # Path to the files shared by tests, and to the nanopb core. -env.Append(CPPPATH = ["#../", "#common"]) +env.Append(CPPPATH = ["#../", "$COMMON"]) # Path for finding nanopb.proto env.Append(PROTOCPATH = '#../generator') @@ -110,5 +110,10 @@ elif 'cl' in env['CXX']: env.Append(CXXFLAGS = '/Zi /W2 /WX') # Now include the SConscript files from all subdirectories -SConscript(Glob('*/SConscript'), exports = 'env') +import os.path +env['VARIANT_DIR'] = 'build' +env['BUILD'] = '#' + env['VARIANT_DIR'] +env['COMMON'] = '#' + env['VARIANT_DIR'] + '/common' +for subdir in Glob('*/SConscript'): + SConscript(subdir, exports = 'env', variant_dir = env['VARIANT_DIR'] + '/' + os.path.dirname(str(subdir))) diff --git a/tests/alltypes/SConscript b/tests/alltypes/SConscript index 8aa45b6..1dc6f87 100644 --- a/tests/alltypes/SConscript +++ b/tests/alltypes/SConscript @@ -3,9 +3,9 @@ Import("env") -env.NanopbProto("alltypes") -enc = env.Program(["encode_alltypes.c", "alltypes.pb.c", "#common/pb_encode.o"]) -dec = env.Program(["decode_alltypes.c", "alltypes.pb.c", "#common/pb_decode.o"]) +env.NanopbProto(["alltypes", "alltypes.options"]) +enc = env.Program(["encode_alltypes.c", "alltypes.pb.c", "$COMMON/pb_encode.o"]) +dec = env.Program(["decode_alltypes.c", "alltypes.pb.c", "$COMMON/pb_decode.o"]) env.RunTest(enc) env.RunTest([dec, "encode_alltypes.output"]) diff --git a/tests/backwards_compatibility/SConscript b/tests/backwards_compatibility/SConscript index 5fb978f..777ef40 100644 --- a/tests/backwards_compatibility/SConscript +++ b/tests/backwards_compatibility/SConscript @@ -3,8 +3,8 @@ Import("env") -enc = env.Program(["encode_legacy.c", "alltypes_legacy.c", "#common/pb_encode.o"]) -dec = env.Program(["decode_legacy.c", "alltypes_legacy.c", "#common/pb_decode.o"]) +enc = env.Program(["encode_legacy.c", "alltypes_legacy.c", "$COMMON/pb_encode.o"]) +dec = env.Program(["decode_legacy.c", "alltypes_legacy.c", "$COMMON/pb_decode.o"]) env.RunTest(enc) env.RunTest([dec, "encode_legacy.output"]) diff --git a/tests/basic_buffer/SConscript b/tests/basic_buffer/SConscript index 349fb14..2546aaa 100644 --- a/tests/basic_buffer/SConscript +++ b/tests/basic_buffer/SConscript @@ -2,11 +2,11 @@ Import("env") -enc = env.Program(["encode_buffer.c", "#common/person.pb.c", "#common/pb_encode.o"]) -dec = env.Program(["decode_buffer.c", "#common/person.pb.c", "#common/pb_decode.o"]) +enc = env.Program(["encode_buffer.c", "$COMMON/person.pb.c", "$COMMON/pb_encode.o"]) +dec = env.Program(["decode_buffer.c", "$COMMON/person.pb.c", "$COMMON/pb_decode.o"]) env.RunTest(enc) env.RunTest([dec, "encode_buffer.output"]) -env.Decode(["encode_buffer.output", "#common/person.proto"], MESSAGE = "Person") +env.Decode(["encode_buffer.output", "$COMMON/person.proto"], MESSAGE = "Person") env.Compare(["decode_buffer.output", "encode_buffer.decoded"]) diff --git a/tests/basic_stream/SConscript b/tests/basic_stream/SConscript index 17382a9..46db8c4 100644 --- a/tests/basic_stream/SConscript +++ b/tests/basic_stream/SConscript @@ -2,11 +2,11 @@ Import("env") -enc = env.Program(["encode_stream.c", "#common/person.pb.c", "#common/pb_encode.o"]) -dec = env.Program(["decode_stream.c", "#common/person.pb.c", "#common/pb_decode.o"]) +enc = env.Program(["encode_stream.c", "$COMMON/person.pb.c", "$COMMON/pb_encode.o"]) +dec = env.Program(["decode_stream.c", "$COMMON/person.pb.c", "$COMMON/pb_decode.o"]) env.RunTest(enc) env.RunTest([dec, "encode_stream.output"]) -env.Decode(["encode_stream.output", "#common/person.proto"], MESSAGE = "Person") +env.Decode(["encode_stream.output", "$COMMON/person.proto"], MESSAGE = "Person") env.Compare(["decode_stream.output", "encode_stream.decoded"]) diff --git a/tests/buffer_only/SConscript b/tests/buffer_only/SConscript index 0770b2f..db86d37 100644 --- a/tests/buffer_only/SConscript +++ b/tests/buffer_only/SConscript @@ -6,10 +6,10 @@ Import("env") c = Copy("$TARGET", "$SOURCE") env.Command("pb_encode.c", "#../pb_encode.c", c) env.Command("pb_decode.c", "#../pb_decode.c", c) -env.Command("alltypes.pb.h", "#alltypes/alltypes.pb.h", c) -env.Command("alltypes.pb.c", "#alltypes/alltypes.pb.c", c) -env.Command("encode_alltypes.c", "#alltypes/encode_alltypes.c", c) -env.Command("decode_alltypes.c", "#alltypes/decode_alltypes.c", c) +env.Command("alltypes.pb.h", "$BUILD/alltypes/alltypes.pb.h", c) +env.Command("alltypes.pb.c", "$BUILD/alltypes/alltypes.pb.c", c) +env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c) +env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c) # Define the compilation options opts = env.Clone() diff --git a/tests/callbacks/SConscript b/tests/callbacks/SConscript index 729fd65..9ec8a43 100644 --- a/tests/callbacks/SConscript +++ b/tests/callbacks/SConscript @@ -3,8 +3,8 @@ Import("env") env.NanopbProto("callbacks") -enc = env.Program(["encode_callbacks.c", "callbacks.pb.c", "#common/pb_encode.o"]) -dec = env.Program(["decode_callbacks.c", "callbacks.pb.c", "#common/pb_decode.o"]) +enc = env.Program(["encode_callbacks.c", "callbacks.pb.c", "$COMMON/pb_encode.o"]) +dec = env.Program(["decode_callbacks.c", "callbacks.pb.c", "$COMMON/pb_decode.o"]) env.RunTest(enc) env.RunTest([dec, "encode_callbacks.output"]) diff --git a/tests/cxx_main_program/SConscript b/tests/cxx_main_program/SConscript index 055c5ae..4bca1b1 100644 --- a/tests/cxx_main_program/SConscript +++ b/tests/cxx_main_program/SConscript @@ -7,10 +7,10 @@ Import("env") c = Copy("$TARGET", "$SOURCE") env.Command("pb_encode.cxx", "#../pb_encode.c", c) env.Command("pb_decode.cxx", "#../pb_decode.c", c) -env.Command("alltypes.pb.h", "#alltypes/alltypes.pb.h", c) -env.Command("alltypes.pb.cxx", "#alltypes/alltypes.pb.c", c) -env.Command("encode_alltypes.cxx", "#alltypes/encode_alltypes.c", c) -env.Command("decode_alltypes.cxx", "#alltypes/decode_alltypes.c", c) +env.Command("alltypes.pb.h", "$BUILD/alltypes/alltypes.pb.h", c) +env.Command("alltypes.pb.cxx", "$BUILD/alltypes/alltypes.pb.c", c) +env.Command("encode_alltypes.cxx", "$BUILD/alltypes/encode_alltypes.c", c) +env.Command("decode_alltypes.cxx", "$BUILD/alltypes/decode_alltypes.c", c) # Now build and run the test normally. enc = env.Program(["encode_alltypes.cxx", "alltypes.pb.cxx", "pb_encode.cxx"]) diff --git a/tests/decode_unittests/SConscript b/tests/decode_unittests/SConscript index 9a639f7..369b9dc 100644 --- a/tests/decode_unittests/SConscript +++ b/tests/decode_unittests/SConscript @@ -1,4 +1,4 @@ Import('env') -p = env.Program(["decode_unittests.c", "#common/unittestproto.pb.c"]) +p = env.Program(["decode_unittests.c", "$COMMON/unittestproto.pb.c"]) env.RunTest(p) diff --git a/tests/encode_unittests/SConscript b/tests/encode_unittests/SConscript index 7509ec0..bf6d140 100644 --- a/tests/encode_unittests/SConscript +++ b/tests/encode_unittests/SConscript @@ -1,5 +1,5 @@ # Build and run the stand-alone unit tests for the nanopb encoder part. Import('env') -p = env.Program(["encode_unittests.c", "#common/unittestproto.pb.c"]) +p = env.Program(["encode_unittests.c", "$COMMON/unittestproto.pb.c"]) env.RunTest(p) diff --git a/tests/extensions/SConscript b/tests/extensions/SConscript index f632a9a..26fc5a3 100644 --- a/tests/extensions/SConscript +++ b/tests/extensions/SConscript @@ -4,12 +4,12 @@ Import("env") # We use the files from the alltypes test case incpath = env.Clone() -incpath.Append(PROTOCPATH = '#alltypes') -incpath.Append(CPPPATH = '#alltypes') +incpath.Append(PROTOCPATH = '$BUILD/alltypes') +incpath.Append(CPPPATH = '$BUILD/alltypes') -incpath.NanopbProto("extensions") -enc = incpath.Program(["encode_extensions.c", "extensions.pb.c", "#alltypes/alltypes.pb$OBJSUFFIX", "#common/pb_encode.o"]) -dec = incpath.Program(["decode_extensions.c", "extensions.pb.c", "#alltypes/alltypes.pb$OBJSUFFIX", "#common/pb_decode.o"]) +incpath.NanopbProto(["extensions", "extensions.options"]) +enc = incpath.Program(["encode_extensions.c", "extensions.pb.c", "$BUILD/alltypes/alltypes.pb$OBJSUFFIX", "$COMMON/pb_encode.o"]) +dec = incpath.Program(["decode_extensions.c", "extensions.pb.c", "$BUILD/alltypes/alltypes.pb$OBJSUFFIX", "$COMMON/pb_decode.o"]) env.RunTest(enc) env.RunTest([dec, "encode_extensions.output"]) diff --git a/tests/extra_fields/SConscript b/tests/extra_fields/SConscript index 9227e95..797c4e6 100644 --- a/tests/extra_fields/SConscript +++ b/tests/extra_fields/SConscript @@ -2,13 +2,13 @@ Import("env") -dec = env.GetBuildPath('#basic_buffer/${PROGPREFIX}decode_buffer${PROGSUFFIX}') +dec = env.GetBuildPath('$BUILD/basic_buffer/${PROGPREFIX}decode_buffer${PROGSUFFIX}') env.RunTest('person_with_extra_field.output', [dec, "person_with_extra_field.pb"]) env.Compare(["person_with_extra_field.output", "person_with_extra_field.expected"]) -dec = env.GetBuildPath('#basic_stream/${PROGPREFIX}decode_stream${PROGSUFFIX}') +dec = env.GetBuildPath('$BUILD/basic_stream/${PROGPREFIX}decode_stream${PROGSUFFIX}') env.RunTest('person_with_extra_field_stream.output', [dec, "person_with_extra_field.pb"]) env.Compare(["person_with_extra_field_stream.output", "person_with_extra_field.expected"]) -dec2 = env.GetBuildPath('#alltypes/${PROGPREFIX}decode_alltypes${PROGSUFFIX}') +dec2 = env.GetBuildPath('$BUILD/alltypes/${PROGPREFIX}decode_alltypes${PROGSUFFIX}') env.RunTest('alltypes_with_extra_fields.output', [dec2, 'alltypes_with_extra_fields.pb']) diff --git a/tests/field_size_16/SConscript b/tests/field_size_16/SConscript index 48d08e8..15dc0f5 100644 --- a/tests/field_size_16/SConscript +++ b/tests/field_size_16/SConscript @@ -7,10 +7,10 @@ Import("env") c = Copy("$TARGET", "$SOURCE") env.Command("pb_encode.c", "#../pb_encode.c", c) env.Command("pb_decode.c", "#../pb_decode.c", c) -env.Command("encode_alltypes.c", "#alltypes/encode_alltypes.c", c) -env.Command("decode_alltypes.c", "#alltypes/decode_alltypes.c", c) +env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c) +env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c) -env.NanopbProto("alltypes") +env.NanopbProto(["alltypes", "alltypes.options"]) # Define the compilation options opts = env.Clone() diff --git a/tests/field_size_32/SConscript b/tests/field_size_32/SConscript index a8584dc..25ef354 100644 --- a/tests/field_size_32/SConscript +++ b/tests/field_size_32/SConscript @@ -7,10 +7,10 @@ Import("env") c = Copy("$TARGET", "$SOURCE") env.Command("pb_encode.c", "#../pb_encode.c", c) env.Command("pb_decode.c", "#../pb_decode.c", c) -env.Command("encode_alltypes.c", "#alltypes/encode_alltypes.c", c) -env.Command("decode_alltypes.c", "#alltypes/decode_alltypes.c", c) +env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c) +env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c) -env.NanopbProto("alltypes") +env.NanopbProto(["alltypes", "alltypes.options"]) # Define the compilation options opts = env.Clone() diff --git a/tests/missing_fields/SConscript b/tests/missing_fields/SConscript index 361b550..9926efa 100644 --- a/tests/missing_fields/SConscript +++ b/tests/missing_fields/SConscript @@ -3,6 +3,6 @@ Import("env") env.NanopbProto("missing_fields") -test = env.Program(["missing_fields.c", "missing_fields.pb.c", "#common/pb_encode.o", "#common/pb_decode.o"]) +test = env.Program(["missing_fields.c", "missing_fields.pb.c", "$COMMON/pb_encode.o", "$COMMON/pb_decode.o"]) env.RunTest(test) diff --git a/tests/no_errmsg/SConscript b/tests/no_errmsg/SConscript index 870e894..2b9815d 100644 --- a/tests/no_errmsg/SConscript +++ b/tests/no_errmsg/SConscript @@ -6,10 +6,10 @@ Import("env") c = Copy("$TARGET", "$SOURCE") env.Command("pb_encode.c", "#../pb_encode.c", c) env.Command("pb_decode.c", "#../pb_decode.c", c) -env.Command("alltypes.pb.h", "#alltypes/alltypes.pb.h", c) -env.Command("alltypes.pb.c", "#alltypes/alltypes.pb.c", c) -env.Command("encode_alltypes.c", "#alltypes/encode_alltypes.c", c) -env.Command("decode_alltypes.c", "#alltypes/decode_alltypes.c", c) +env.Command("alltypes.pb.h", "$BUILD/alltypes/alltypes.pb.h", c) +env.Command("alltypes.pb.c", "$BUILD/alltypes/alltypes.pb.c", c) +env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c) +env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c) # Define the compilation options opts = env.Clone() -- 2.16.6