Skip to content

Commit 56dad30

Browse files
copilot: Update CI job to check for MISRA compliance with cppcheck. Refs #472.
It has been determined that Copilot-generated code should comply with the MISRA C coding standard. To ensure that future versions of Copilot keep complying with MISRA, this commit modifies the CI job to check a sample file for compliance using cppcheck. Note that the version of cppcheck included with xenial, which is the distribution used currently by Travis by default, does not include a version of cppcheck modern enough to accept the flag --addon=misra.py. Consequently, we update the dist to be focal.
1 parent a867e72 commit 56dad30

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

.travis.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# dist should be at least focal because we need cppcheck >= 1.88.
2+
dist: focal
3+
14
# NB: don't set `language: haskell` here
25

36
# The following enables several GHC versions to be tested; often it's enough to
@@ -16,9 +19,9 @@ before_install:
1619
- travis_retry sudo apt-get update
1720
- travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER # see note about happy/alex
1821

19-
# We install z3 only for the tests, since it is not needed for normal
20-
# compilation.
21-
- if [ "${GHCVER}" == "8.10.4" ]; then travis_retry sudo apt-get install --yes z3; fi
22+
# We install z3 and cppcheck only for the tests, since they are not needed
23+
# for normal compilation.
24+
- if [ "${GHCVER}" == "8.10.4" ]; then travis_retry sudo apt-get install --yes z3 cppcheck; fi
2225

2326
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
2427
- cabal --version
@@ -27,7 +30,10 @@ before_install:
2730
- git submodule update --remote
2831

2932
script:
30-
- travis_wait 30 cabal v2-install --lib copilot
33+
# We explicitly install all libraries so that they are exposed and we can use
34+
# them for tests (e.g., with runhaskell). There is no harm in doing this
35+
# instead of installing just copilot.
36+
- travis_wait 30 cabal v2-install --lib copilot copilot-core copilot-c99 copilot-language copilot-libraries copilot-theorem copilot-interpreter copilot-prettyprinter
3137

3238
# Run tests only on GHC 8.10.4
3339
#
@@ -37,3 +43,8 @@ script:
3743
# conditional installation, and keep GHC version numbers in both places in
3844
# sync.
3945
- if [ "${GHCVER}" == "8.10.4" ]; then cabal v2-test -j1 copilot-core copilot-language copilot-interpreter copilot-c99 copilot-theorem copilot-libraries; fi
46+
47+
# Check that the code produced by Copilot complies with MISRA C 2012. We
48+
# explicitly make cppcheck produce a non-zero exit code on non-compliance
49+
# with the standard to make the CI build fail.
50+
- if [ "${GHCVER}" == "8.10.4" ]; then runhaskell copilot/examples/Heater.hs; cppcheck --force --addon=misra.py --suppress=misra-c2012-14.4 --error-exitcode=2 heater.c; fi

0 commit comments

Comments
 (0)