Skip to content

Commit

Permalink
Fix-test-sources-to-work-locally (#6609)
Browse files Browse the repository at this point in the history
* Support specifying non-system clang-format via CLANG_FORMAT environment variable.

* Add additional build dir for cppcheck to skip.

* Skip header test for git-ignored files and files in webots_ros.

* Skip texture tests for jpgs that are thumbnails.

* Workaround false-positive issued by pyflakes-3.0.1.
  • Loading branch information
brettle authored Aug 2, 2024
1 parent 81bdae2 commit 02900c7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
5 changes: 3 additions & 2 deletions scripts/converter/convert_nue_to_enu_rub_to_flu.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,9 @@ def convert_nue_to_enu_world(filename, mode='all', objects_pi=[], objects_pi_2=[
error_verbose, clean_verbose, warning_verbose = convert_nue_to_enu_world(
filename, mode, objects_pi, objects_pi_2, objects_minus_pi_2)
if error_verbose:
print('''Conversion of \033[33m{}\033[m successful but incomplete. \r\n
■ You may need to convert manually: {}'''.format(filename, error_verbose))
msg = '''Conversion of \033[33m{}\033[m successful but incomplete. \r\n
■ You may need to convert manually: {}'''
print(msg.format(filename, error_verbose))
else:
if mode == 'clean':
print('clean of {} ✅'.format(filename))
Expand Down
5 changes: 3 additions & 2 deletions tests/sources/test_clang_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ class TestClangFormat(unittest.TestCase):
def setUp(self):
"""Set up called before each test."""
self.WEBOTS_HOME = os.path.normpath(os.environ['WEBOTS_HOME'])
self.CLANG_FORMAT = os.environ.get('CLANG_FORMAT', 'clang-format')

def _runClangFormat(self, f):
"""Run clang format on 'f' file."""
return subprocess.check_output(['clang-format', '-style=file', f])
return subprocess.check_output([self.CLANG_FORMAT, '-style=file', f])

def test_clang_format_is_correctly_installed(self):
"""Test ClangFormat is correctly installed."""
self.assertTrue(
shutil.which('clang-format') is not None,
shutil.which(self.CLANG_FORMAT) is not None,
msg='ClangFormat is not installed on this computer.'
)
clangFormatConfigFile = os.path.join(self.WEBOTS_HOME, '.clang-format')
Expand Down
3 changes: 2 additions & 1 deletion tests/sources/test_cppcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ def test_projects_with_cppcheck(self):
'projects/vehicles/controllers/ros_automobile/include',
'projects/robots/gctronic/e-puck/plugins/robot_windows/botstudio/build',
'projects/robots/nex/plugins/robot_windows/fire_bird_6_window/build',
'projects/vehicles/plugins/robot_windows/automobile_window/build'
'projects/vehicles/plugins/robot_windows/automobile_window/build',
'projects/robots/robotis/darwin-op/plugins/robot_windows/robotis-op2_window/build'
]
skippedFiles = [
'projects/robots/robotis/darwin-op/plugins/remote_controls/robotis-op2_tcpip/stb_image.h',
Expand Down
6 changes: 5 additions & 1 deletion tests/sources/test_header_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import unittest
import os
import fnmatch
import subprocess

IGNORED_PROTOS = [
'projects/robots/mobsya/thymio/controllers/thymio2_aseba/aseba/aseba/clients/studio/plugins/ThymioVPL/UsageProfile.proto',
Expand All @@ -32,6 +33,7 @@
]

SKIPPED_DIRECTORIES = [
'webots_ros',
'dependencies',
'distribution',
'.git'
Expand Down Expand Up @@ -73,7 +75,9 @@ def setUp(self):
dirNames[:] = [d for d in dirNames if d not in SKIPPED_DIRECTORIES]
for fileName in fnmatch.filter(fileNames, '*.wbproj'):
projFile = os.path.join(rootPath, fileName)
self.files.append((projFile, 'Webots Project File version %s' % self.version))
# Only check files that aren't ignored by git
if subprocess.run(['git', 'check-ignore', '-q', projFile]).returncode != 0:
self.files.append((projFile, 'Webots Project File version %s' % self.version))

def test_header_version(self):
"""Test that the PROTO and world files have the correct header."""
Expand Down
3 changes: 3 additions & 0 deletions tests/sources/test_textures.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def setUp(self):
image = os.path.join(rootPath, fileName)
images.append(image)
for fileName in fnmatch.filter(fileNames, '*.jpg'):
# Ignore thumbnails
if fileName.startswith('.'):
continue
image = os.path.join(rootPath, fileName)
images.append(image)
# 2. filter-out the images which are not textures
Expand Down

0 comments on commit 02900c7

Please sign in to comment.