Skip to content
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

test: define default clang args for testing #256

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 0 additions & 3 deletions test/cpp/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@ directives:
directive: autodoc
arguments:
- template.cpp
options:
clang:
- --std=c++17
expected: template.rst
20 changes: 18 additions & 2 deletions test/testenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,37 @@ def get_input_filename(self):

return self.testcase.get_relative_filename(basename)

def get_directive_string(self):
def get_directive_string(self, example=False):
arguments_str = ' '.join(self.arguments)
directive_str = f'.. {self.domain}:{self.directive}:: {arguments_str}\n'

for key, value in self.options.items():
if example:
# Use the options verbatim in documenting the examples.
options = self.options
else:
# Insert the default clang args for testing.
options = self.options.copy()
options['clang'] = self.get_clang_args()

for key, value in options.items():
if isinstance(value, list):
value = ', '.join(value)
space = ' ' if len(value) else ''
directive_str += f' :{key}:{space}{value}\n'

return directive_str

def _get_default_clang_args(self):
if self.domain == 'c':
return ['-std=c17']
else:
return ['-std=c++17']

def get_clang_args(self):
clang_args = []

clang_args.extend(self._get_default_clang_args())

clang_args.extend(self.options.get('clang', []))

return clang_args
Expand Down
2 changes: 1 addition & 1 deletion test/update-examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def print_example(testcase):
namespace_push = ''
namespace_pop = ''

directive_str = testcase.directives[0].get_directive_string()
directive_str = testcase.directives[0].get_directive_string(example=True)

print(f'''Directive
~~~~~~~~~
Expand Down
Loading