@@ -1961,76 +1961,44 @@ def test_path_to_name(path):
1961
1961
name_parts .insert (0 , tail )
1962
1962
head , tail = os .path .split (head )
1963
1963
1964
- return "-" .join (name_parts )
1964
+ return "-" .join (name_parts ). lower ()
1965
1965
1966
1966
def find_tests (base_dir ):
1967
1967
"""Given any directory, walk through the subdirectories and find all tests"""
1968
1968
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 ):
1976
1970
"""Given a 'TESTS' directory, return a dictionary of test names and test paths.
1977
1971
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
+ }
1990
1982
1991
- return tests
1992
-
1983
+ return test
1984
+
1993
1985
tests_path = 'TESTS'
1986
+ tests = {}
1987
+ dirs = scan_for_source_paths (base_dir )
1994
1988
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' ]
1997
1993
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
2028
1995
2029
- def print_tests (tests , format = "list" ):
1996
+ def print_tests (tests , format = "list" , sort = True ):
2030
1997
"""Given a dictionary of tests (as returned from "find_tests"), print them
2031
1998
in the specified format"""
2032
1999
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 ]
2034
2002
print "Test Case:"
2035
2003
print " Name: %s" % test_name
2036
2004
print " Path: %s" % test_path
@@ -2064,7 +2032,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
2064
2032
for test_name , test_path in tests .iteritems ():
2065
2033
test_build_path = os .path .join (build_path , test_path )
2066
2034
src_path = base_source_paths + [test_path ]
2067
-
2035
+ bin_file = None
2068
2036
try :
2069
2037
bin_file = build_project (src_path , test_build_path , target , toolchain_name ,
2070
2038
options = options ,
@@ -2077,30 +2045,32 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
2077
2045
verbose = verbose )
2078
2046
2079
2047
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
2086
2055
2087
2056
# If a clean build was carried out last time, disable it for the next build.
2088
2057
# Otherwise the previously built test will be deleted.
2089
2058
if clean :
2090
2059
clean = False
2091
2060
2092
2061
# 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
2104
2074
2105
2075
test_builds = {}
2106
2076
test_builds ["%s-%s" % (target .name , toolchain_name )] = test_build
0 commit comments