Skip to content

Adding the ability for tests to report they aren't supported on a target #1568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions workspace_tools/build_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from os.path import join, exists, basename
from time import time

from workspace_tools.utils import mkdir, run_cmd, run_cmd_ext
from workspace_tools.utils import mkdir, run_cmd, run_cmd_ext, NotSupportedException
from workspace_tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, MBED_HAL, MBED_COMMON
from workspace_tools.targets import TARGET_NAMES, TARGET_MAP
from workspace_tools.libraries import Library
Expand Down Expand Up @@ -139,13 +139,13 @@ def build_project(src_path, build_path, target, toolchain_name,
resources.inc_dirs.extend(inc_dirs)
else:
resources.inc_dirs.append(inc_dirs)

# Compile Sources
for path in src_paths:
src = toolchain.scan_resources(path)
objects = toolchain.compile_sources(src, build_path, resources.inc_dirs)
resources.objects.extend(objects)


# Link Program
res, needed_update = toolchain.link_program(resources, build_path, name)

Expand All @@ -162,7 +162,12 @@ def build_project(src_path, build_path, target, toolchain_name,
except Exception, e:
if report != None:
end = time()
cur_result["result"] = "FAIL"

if isinstance(e, NotSupportedException):
cur_result["result"] = "NOT_SUPPORTED"
else:
cur_result["result"] = "FAIL"

cur_result["elapsed_time"] = end - start

toolchain_output = toolchain.get_output()
Expand Down
28 changes: 21 additions & 7 deletions workspace_tools/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from workspace_tools.paths import BUILD_DIR
from workspace_tools.paths import HOST_TESTS
from workspace_tools.utils import ToolException
from workspace_tools.utils import NotSupportedException
from workspace_tools.utils import construct_enum
from workspace_tools.targets import TARGET_MAP
from workspace_tools.test_db import BaseDBAccess
Expand Down Expand Up @@ -130,6 +131,7 @@ class SingleTestRunner(object):
TEST_RESULT_NO_IMAGE = "NO_IMAGE"
TEST_RESULT_MBED_ASSERT = "MBED_ASSERT"
TEST_RESULT_BUILD_FAILED = "BUILD_FAILED"
TEST_RESULT_NOT_SUPPORTED = "NOT_SUPPORTED"

GLOBAL_LOOPS_COUNT = 1 # How many times each test should be repeated
TEST_LOOPS_LIST = [] # We redefine no.of loops per test_id
Expand All @@ -149,7 +151,8 @@ class SingleTestRunner(object):
"no_image" : TEST_RESULT_NO_IMAGE,
"end" : TEST_RESULT_UNDEF,
"mbed_assert" : TEST_RESULT_MBED_ASSERT,
"build_failed" : TEST_RESULT_BUILD_FAILED
"build_failed" : TEST_RESULT_BUILD_FAILED,
"not_supproted" : TEST_RESULT_NOT_SUPPORTED
}

def __init__(self,
Expand Down Expand Up @@ -476,27 +479,37 @@ def execute_thread_slice(self, q, target, toolchains, clean, test_ids, build_rep
project_id=test_id,
project_description=test.get_description())

except ToolException:
except Exception, e:
project_name_str = project_name if project_name is not None else test_id
print self.logger.log_line(self.logger.LogType.ERROR, 'There were errors while building project %s'% (project_name_str))


test_result = self.TEST_RESULT_FAIL

if isinstance(e, ToolException):
print self.logger.log_line(self.logger.LogType.ERROR, 'There were errors while building project %s'% (project_name_str))
test_result = self.TEST_RESULT_BUILD_FAILED
elif isinstance(e, NotSupportedException):
print self.logger.log_line(self.logger.LogType.INFO, 'The project %s is not supported'% (project_name_str))
test_result = self.TEST_RESULT_NOT_SUPPORTED


# Append test results to global test summary
self.test_summary.append(
(self.TEST_RESULT_BUILD_FAILED, target, toolchain, test_id, 'Toolchain build failed', 0, 0, '-')
(test_result, target, toolchain, test_id, test.get_description(), 0, 0, '-')
)

# Add detailed test result to test summary structure
if test_id not in self.test_summary_ext[target][toolchain]:
self.test_summary_ext[target][toolchain][test_id] = []

self.test_summary_ext[target][toolchain][test_id].append({ 0: {
'result' : self.TEST_RESULT_BUILD_FAILED,
'result' : test_result,
'output' : '',
'target_name' : target,
'target_name_unique': target,
'toolchain_name' : toolchain,
'id' : test_id,
'description' : 'Toolchain build failed',
'description' : test.get_description(),
'elapsed_time' : 0,
'duration' : 0,
'copy_method' : None
Expand Down Expand Up @@ -736,7 +749,8 @@ def generate_test_summary(self, test_summary, shuffle_seed=None):
self.TEST_RESULT_NO_IMAGE : 0,
self.TEST_RESULT_TIMEOUT : 0,
self.TEST_RESULT_MBED_ASSERT : 0,
self.TEST_RESULT_BUILD_FAILED : 0
self.TEST_RESULT_BUILD_FAILED : 0,
self.TEST_RESULT_NOT_SUPPORTED : 0
}

for test in test_summary:
Expand Down
6 changes: 3 additions & 3 deletions workspace_tools/test_exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def exporter_junit_ioper(self, test_result_ext, test_suite_properties=None):
tc.add_failure_info(description, _stdout)
elif result == 'ERROR':
tc.add_error_info(description, _stdout)
elif result == 'SKIP':
elif result == 'SKIP' or result == 'NOT_SUPPORTED':
tc.add_skipped_info(description, _stdout)

test_cases.append(tc)
Expand Down Expand Up @@ -282,7 +282,7 @@ def exporter_junit(self, test_result_ext, test_suite_properties=None):
message = test_result['result']
if test_result['result'] == 'FAIL':
tc.add_failure_info(message, _stdout)
elif test_result['result'] == 'SKIP':
elif test_result['result'] == 'SKIP' or test_result["result"] == 'NOT_SUPPORTED':
tc.add_skipped_info(message, _stdout)
elif test_result['result'] != 'OK':
tc.add_error_info(message, _stdout)
Expand Down Expand Up @@ -319,7 +319,7 @@ def exporter_print(self, test_result_ext):

if test_run["result"] == "FAIL":
failures.append(test_run)
elif test_run["result"] == "SKIP":
elif test_run["result"] == "SKIP" or test_run["result"] == "NOT_SUPPORTED":
skips.append(test_run)
elif test_run["result"] == "OK":
successes.append(test_run)
Expand Down
10 changes: 8 additions & 2 deletions workspace_tools/toolchains/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from inspect import getmro

from multiprocessing import Pool, cpu_count
from workspace_tools.utils import run_cmd, mkdir, rel_path, ToolException, split_path
from workspace_tools.utils import run_cmd, mkdir, rel_path, ToolException, NotSupportedException, split_path
from workspace_tools.settings import BUILD_OPTIONS, MBED_ORG_USER
import workspace_tools.hooks as hooks

Expand Down Expand Up @@ -604,6 +604,9 @@ def compile_command(self, source, object, includes):

return None

def is_not_supported_error(self, output):
return "#error directive: [NOT_SUPPORTED]" in output

def compile_output(self, output=[]):
_rc = output[0]
_stderr = output[1]
Expand All @@ -621,7 +624,10 @@ def compile_output(self, output=[]):
for line in _stderr.splitlines():
self.tool_error(line)

raise ToolException(_stderr)
if self.is_not_supported_error(_stderr):
raise NotSupportedException(_stderr)
else:
raise ToolException(_stderr)

def compile(self, cc, source, object, includes):
_, ext = splitext(source)
Expand Down
3 changes: 3 additions & 0 deletions workspace_tools/toolchains/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ def parse_dependencies(self, dep_path):
dependencies = dependencies + [f.replace('\a', ' ') for f in file.split(" ")]
return dependencies

def is_not_supported_error(self, output):
return "error: #error [NOT_SUPPORTED]" in output

def parse_output(self, output):
# The warning/error notification is multiline
WHERE, WHAT = 0, 1
Expand Down
2 changes: 2 additions & 0 deletions workspace_tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def rel_path(path, base, dot=False):
class ToolException(Exception):
pass

class NotSupportedException(Exception):
pass

def split_path(path):
base, file = split(path)
Expand Down