@@ -1961,76 +1961,44 @@ def test_path_to_name(path):
19611961 name_parts .insert (0 , tail )
19621962 head , tail = os .path .split (head )
19631963
1964- return "-" .join (name_parts )
1964+ return "-" .join (name_parts ). lower ()
19651965
19661966def find_tests (base_dir ):
19671967 """Given any directory, walk through the subdirectories and find all tests"""
19681968
1969- def is_subdir (path , directory ):
1970- path = os .path .realpath (path )
1971- directory = os .path .realpath (directory )
1972- relative = os .path .relpath (path , directory )
1973- return not (relative .startswith (os .pardir + os .sep ) and relative .startswith (os .pardir ))
1974-
1975- def find_tests_in_tests_directory (directory ):
1969+ def find_test_in_directory (directory , tests_path ):
19761970 """Given a 'TESTS' directory, return a dictionary of test names and test paths.
19771971 The formate of the dictionary is {"test-name": "./path/to/test"}"""
1978- tests = {}
1979-
1980- for d in os .listdir (directory ):
1981- # dir name host_tests is reserved for host python scripts.
1982- if d != "host_tests" :
1983- # Loop on test case directories
1984- for td in os .listdir (os .path .join (directory , d )):
1985- # Add test case to the results if it is a directory and not "host_tests"
1986- if td != "host_tests" :
1987- test_case_path = os .path .join (directory , d , td )
1988- if os .path .isdir (test_case_path ):
1989- tests [test_path_to_name (test_case_path )] = test_case_path
1972+ test = None
1973+ if tests_path in directory :
1974+ head , test_case_directory = os .path .split (directory )
1975+ if test_case_directory != tests_path and test_case_directory != "host_tests" :
1976+ head , test_group_directory = os .path .split (head )
1977+ if test_group_directory != tests_path and test_case_directory != "host_tests" :
1978+ test = {
1979+ "name" : test_path_to_name (directory ),
1980+ "path" : directory
1981+ }
19901982
1991- return tests
1992-
1983+ return test
1984+
19931985 tests_path = 'TESTS'
1986+ tests = {}
1987+ dirs = scan_for_source_paths (base_dir )
19941988
1995- # Determine if "base_dir" is already a "TESTS" directory
1996- _ , top_folder = os .path .split (base_dir )
1989+ for directory in dirs :
1990+ test = find_test_in_directory (directory , tests_path )
1991+ if test :
1992+ tests [test ['name' ]] = test ['path' ]
19971993
1998- if top_folder == tests_path :
1999- # Already pointing at a "TESTS" directory
2000- return find_tests_in_tests_directory (base_dir )
2001- else :
2002- # Not pointing at a "TESTS" directory, so go find one!
2003- tests = {}
2004-
2005- dirs = scan_for_source_paths (base_dir )
2006-
2007- test_and_sub_dirs = [x for x in dirs if tests_path in x ]
2008- test_dirs = []
2009- for potential_test_dir in test_and_sub_dirs :
2010- good_to_add = True
2011- if test_dirs :
2012- for test_dir in test_dirs :
2013- if is_subdir (potential_test_dir , test_dir ):
2014- good_to_add = False
2015- break
2016-
2017- if good_to_add :
2018- test_dirs .append (potential_test_dir )
2019-
2020- # Only look at valid paths
2021- for path in test_dirs :
2022- # Get the tests inside of the "TESTS" directory
2023- new_tests = find_tests_in_tests_directory (path )
2024- if new_tests :
2025- tests .update (new_tests )
2026-
2027- return tests
1994+ return tests
20281995
2029- def print_tests (tests , format = "list" ):
1996+ def print_tests (tests , format = "list" , sort = True ):
20301997 """Given a dictionary of tests (as returned from "find_tests"), print them
20311998 in the specified format"""
20321999 if format == "list" :
2033- for test_name , test_path in tests .iteritems ():
2000+ for test_name in sorted (tests .keys ()):
2001+ test_path = tests [test_name ]
20342002 print "Test Case:"
20352003 print " Name: %s" % test_name
20362004 print " Path: %s" % test_path
@@ -2064,7 +2032,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
20642032 for test_name , test_path in tests .iteritems ():
20652033 test_build_path = os .path .join (build_path , test_path )
20662034 src_path = base_source_paths + [test_path ]
2067-
2035+ bin_file = None
20682036 try :
20692037 bin_file = build_project (src_path , test_build_path , target , toolchain_name ,
20702038 options = options ,
@@ -2077,30 +2045,32 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
20772045 verbose = verbose )
20782046
20792047 except Exception , e :
2080- result = False
2081-
2082- if continue_on_build_fail :
2083- continue
2084- else :
2085- break
2048+ if not isinstance (e , NotSupportedException ):
2049+ result = False
2050+
2051+ if continue_on_build_fail :
2052+ continue
2053+ else :
2054+ break
20862055
20872056 # If a clean build was carried out last time, disable it for the next build.
20882057 # Otherwise the previously built test will be deleted.
20892058 if clean :
20902059 clean = False
20912060
20922061 # Normalize the path
2093- bin_file = os .path .normpath (bin_file )
2094-
2095- test_build ['tests' ][test_name ] = {
2096- "binaries" : [
2097- {
2098- "path" : bin_file
2099- }
2100- ]
2101- }
2102-
2103- print 'Image: %s' % bin_file
2062+ if bin_file :
2063+ bin_file = os .path .normpath (bin_file )
2064+
2065+ test_build ['tests' ][test_name ] = {
2066+ "binaries" : [
2067+ {
2068+ "path" : bin_file
2069+ }
2070+ ]
2071+ }
2072+
2073+ print 'Image: %s' % bin_file
21042074
21052075 test_builds = {}
21062076 test_builds ["%s-%s" % (target .name , toolchain_name )] = test_build
0 commit comments