Skip to content

Commit

Permalink
[ci] Add a lint to check for unrunnable tests
Browse files Browse the repository at this point in the history
We have discovered that some unittest have become unrunnable because
we added my mistake dependencies that are marked as only compatible
with the OT platforms. This means that those unittests are then skipped
when running all tests using //...
This commit adds a lint to make sure that all tests are compatible with
the host platform.

Signed-off-by: Amaury Pouly <[email protected]>
  • Loading branch information
pamaury committed Sep 2, 2024
1 parent e9670f7 commit a4c3482
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ jobs:
- bash: ci/scripts/verible-lint.sh fpv
condition: eq(variables['Build.Reason'], 'PullRequest')
displayName: Verible FPV (Verilog lint)
- bash: ci/scripts/check-unrunnable-tests.sh
displayName: Check for unrunnable tests
continueOnError: True

- job: sw_build
displayName: Earl Grey SW Build
Expand Down
18 changes: 18 additions & 0 deletions ci/scripts/check-unrunnable-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

set -e

# Look for all tests are incompatible with host, i.e. unrunnable.
ci/bazelisk.sh cquery 'tests(//sw/device/...)' \
--output=starlark \
--starlark:file=ci/scripts/incompatible_targets.cquery \
| sed '/^$/d' | uniq | sort > output.txt
if [ ! -s output.txt ]; then
echo "The following tests are incompatible with the host platform:"
cat output.txt
exit 1
fi
6 changes: 6 additions & 0 deletions ci/scripts/incompatible_targets.cquery
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Find all targets that are incompatible with the specified platform
# (i.e. host by default).
def format(target):
if "IncompatiblePlatformProvider" in providers(target):
return target.label
return ""

0 comments on commit a4c3482

Please sign in to comment.