[tests] make sure unit tests run after sound file is created
authorPaul Brossier <piem@piem.org>
Thu, 29 Nov 2018 17:38:41 +0000 (18:38 +0100)
committerPaul Brossier <piem@piem.org>
Thu, 29 Nov 2018 17:38:41 +0000 (18:38 +0100)
tests/wscript_build

index 7ae6449..c99a051 100644 (file)
@@ -12,14 +12,17 @@ test_sound_abspath = bld.path.get_bld().make_node(test_sound_target)
 # workaround to double escape backslash characters on windows
 test_sound_abspath = str(test_sound_abspath).replace('\\', '\\\\')
 
 # workaround to double escape backslash characters on windows
 test_sound_abspath = str(test_sound_abspath).replace('\\', '\\\\')
 
-bld(name='create_tests_source',
+b = bld(name='create_tests_source',
     rule='python ${SRC} ${TGT}',
     source='create_tests_source.py',
     target=test_sound_target)
     rule='python ${SRC} ${TGT}',
     source='create_tests_source.py',
     target=test_sound_target)
+# use post() to create the task, keep a reference to it
+b.post()
+create_tests_source = b.tasks[0]
 
 for source_file in programs_sources:
     target = os.path.basename(os.path.splitext(str(source_file))[0])
 
 for source_file in programs_sources:
     target = os.path.basename(os.path.splitext(str(source_file))[0])
-    bld(features = 'c cprogram test',
+    a = bld(features = 'c cprogram test',
             source = source_file,
             target = target,
             includes = includes,
             source = source_file,
             target = target,
             includes = includes,
@@ -28,3 +31,6 @@ for source_file in programs_sources:
             defines = ['AUBIO_UNSTABLE_API=1',
                         'AUBIO_TESTS_SOURCE={}'.format(test_sound_abspath)]
        )
             defines = ['AUBIO_UNSTABLE_API=1',
                         'AUBIO_TESTS_SOURCE={}'.format(test_sound_abspath)]
        )
+    a.post()
+    # make sure the unit_test task runs *after* the source is created
+    a.tasks[-1].set_run_after(create_tests_source)