From: Paul Brossier Date: Thu, 1 Nov 2007 12:56:40 +0000 (+0100) Subject: list_missing_tests: update to check all existing test X-Git-Tag: bzr2git~501 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=79287252163131fd0bf41a7c8abb3863cc22677b;p=aubio.git list_missing_tests: update to check all existing test --- diff --git a/tests/list_missing_python_tests b/tests/list_missing_python_tests deleted file mode 100755 index 33bd8bc0..00000000 --- a/tests/list_missing_python_tests +++ /dev/null @@ -1,37 +0,0 @@ -#! /usr/bin/python - -from glob import glob -from os.path import splitext, exists, join, dirname -import sys - -tst_dir = join(dirname(sys.argv[0]),'python') -src_dir = join(dirname(sys.argv[0]),'..','src') - -if len(sys.argv) > 1: verbose = True -else: verbose = False - -status = 0 - -cfiles = [ file.split('/')[-1] for file in glob(join(src_dir,'*.c')) ] -cfiles.sort() - -for cfile in cfiles: - pythonfile=splitext(cfile)[0]+'.py' - if not exists(pythonfile): - print "%20s [X]" % cfile, "[ ] %s" % pythonfile - status = 1 - elif verbose: - print "%20s [X]" % cfile, "[X] %s" % pythonfile - -pythonfiles = [ file.split('/')[-1] for file in glob(join(tst_dir,'*.py')) ] -pythonfiles.sort() - -for pythonfile in pythonfiles: - cfile=splitext(pythonfile)[0]+'.c' - if not exists(join(src_dir,cfile)): - print "%20s [ ]" % cfile, "[X] %s" % pythonfile - status = 1 - elif verbose: - print "%20s [X]" % cfile, "[X] %s" % pythonfile - -sys.exit(status) diff --git a/tests/list_missing_tests b/tests/list_missing_tests new file mode 100755 index 00000000..a3280597 --- /dev/null +++ b/tests/list_missing_tests @@ -0,0 +1,53 @@ +#! /usr/bin/python + +from glob import glob +from os.path import splitext, exists, join, dirname, basename +import sys + +def check_tst_against_src(src_dir, src_ext, ext_dir, verbose = False, tst_prefix = ''): + src_files = [ basename(file) for file in glob( join(src_dir, '*'+src_ext) ) ] + src_files.sort() + status = 0 + for src_file in src_files: + tst_file = (splitext(src_file)[0] + tst_ext).replace(tst_prefix,"") + if not exists(join(tst_dir,tst_prefix+tst_file)): + print "%20s [X]" % src_file, "[ ] %s" % tst_file + status = 1 + elif verbose: + print "%20s [X]" % src_file, "[X] %s" % tst_file + return status + +def check_src_against_tst(tst_dir, tst_ext, src_dir, verbose = False, tst_prefix = 'test-'): + tst_files = [ basename(file) for file in glob( join(tst_dir, '*'+tst_ext) ) ] + tst_files.sort() + status = 0 + for tst_file in tst_files: + src_file = (splitext(tst_file)[0] + src_ext).replace(tst_prefix,"") + if not exists(join(src_dir,src_file)): + print "%20s [ ]" % src_file, "[X] %s" % tst_file + status = 2 + elif verbose: + print "%20s [X]" % src_file, "[X] %s" % tst_file + return status + +if __name__ == '__main__': + + if len(sys.argv) > 1: verbose = True + else: verbose = False + + src_dir = join(dirname(sys.argv[0]),'..','src') + src_ext = '.c' + + tst_dir = join(dirname(sys.argv[0]),'python') + tst_ext = '.py' + print "%20s " % (" FILES IN " + src_dir) + "|" + " FILES IN " + tst_dir + status = check_tst_against_src(src_dir, src_ext, tst_dir, verbose=verbose) + status += check_src_against_tst(tst_dir, tst_ext, src_dir, verbose=verbose) + + tst_dir = join(dirname(sys.argv[0]),'src') + tst_ext = '.c' + print "%20s " % (" FILES IN " + src_dir) + "|" + " FILES IN " + tst_dir + status += check_tst_against_src(src_dir, src_ext, tst_dir, verbose=verbose, tst_prefix = 'test-') + status += check_src_against_tst(tst_dir, tst_ext, src_dir, verbose=verbose, tst_prefix = 'test-') + + sys.exit(status)