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

Use libclang include path in tests #252

Merged
merged 5 commits into from
Sep 11, 2024
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
2 changes: 0 additions & 2 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install dependencies (apt)
run: sudo apt-get install -y python3-clang python3-pip
- name: Examples check
run: |
. venv
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.alpine-latest
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM alpine:latest
RUN apk add \
py3-clang \
clang-dev \
musl-dev \
make

ARG UID=1000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM fedora:37
FROM fedora:39

RUN dnf -y update && \
dnf -y upgrade && \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM fedora:38
FROM fedora:40

RUN dnf -y update && \
dnf -y upgrade && \
Expand Down
25 changes: 25 additions & 0 deletions docker/Dockerfile.fedora-41
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM fedora:41

RUN dnf -y update && \
dnf -y upgrade && \
dnf -y install \
python3-clang \
make && \
dnf clean all

ARG UID=1000
ARG GID=1000
ARG ARCHIVE

WORKDIR /src

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

ADD ${ARCHIVE} .

RUN sh venv

ENV PATH=".venv/bin:${PATH}"

USER ${UID}:${GID}
4 changes: 2 additions & 2 deletions test/c/autostruct.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Named struct.


.. c:struct:: @anonymous_0a4d6f0b47cde0e9872b6dbde2ad1c1a
.. c:struct:: @anonymous_a63d10331be1a527625db63b8ace540f

Anonymous sub-struct.

Expand All @@ -39,7 +39,7 @@
Member foo.


.. c:union:: @anonymous_22cf17aa0fa6d83246282a58013db249
.. c:union:: @anonymous_69382278a84175c1cbff40d522114b38

Anonymous sub-union.

Expand Down
32 changes: 32 additions & 0 deletions test/c/bool.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <stdbool.h>

/**
* Retain bool instead of using _Bool.
*/
static bool convert_bool;

/**
* Also convert _Bool to bool.
*/
static _Bool convert_Bool;

/**
* Bool function.
*/
bool boolean(bool bar, _Bool baz);

/**
* This is a sample struct
*
* Woohoo.
*/
struct sample_struct {
/**
* bool member
*/
bool bool_member;
/**
* _Bool member
*/
_Bool _Bool_member;
};
32 changes: 32 additions & 0 deletions test/c/bool.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

.. c:var:: static bool convert_bool

Retain bool instead of using _Bool.


.. c:var:: static bool convert_Bool

Also convert _Bool to bool.


.. c:function:: bool boolean(bool bar, bool baz)

Bool function.


.. c:struct:: sample_struct

This is a sample struct

Woohoo.


.. c:member:: bool bool_member

bool member


.. c:member:: bool _Bool_member

_Bool member

6 changes: 6 additions & 0 deletions test/c/bool.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
directives:
- domain: c
directive: autodoc
arguments:
- bool.c
expected: bool.rst
7 changes: 0 additions & 7 deletions test/c/function.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
#include <stdbool.h>

/**
* Foo function.
*/
static inline int foo(int bar, int baz);

/**
* Bool function.
*/
bool boolean(bool bar, _Bool baz);

/**
* No parameters.
*/
Expand Down
5 changes: 0 additions & 5 deletions test/c/function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
Foo function.


.. c:function:: bool boolean(bool bar, bool baz)

Bool function.


.. c:function:: int no_parameters(void)

No parameters.
Expand Down
10 changes: 0 additions & 10 deletions test/c/struct.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <stdbool.h>

/**
* This is a sample struct
*
Expand All @@ -10,14 +8,6 @@ struct sample_struct {
* member
*/
int jesh;
/**
* bool member
*/
bool bool_member;
/**
* _Bool member
*/
_Bool _Bool_member;
/**
* array member
*/
Expand Down
16 changes: 3 additions & 13 deletions test/c/struct.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@
member


.. c:member:: bool bool_member

bool member


.. c:member:: bool _Bool_member

_Bool member


.. c:member:: int array_member[5]

array member
Expand Down Expand Up @@ -49,7 +39,7 @@
foo next


.. c:struct:: @anonymous_a6168a23d6840e8919ade5661a307607
.. c:struct:: @anonymous_7bf120438d254a91e1275b973de6a0eb

Anonymous struct documentation.

Expand All @@ -64,7 +54,7 @@
Named struct.


.. c:struct:: @anonymous_0a4d6f0b47cde0e9872b6dbde2ad1c1a
.. c:struct:: @anonymous_a63d10331be1a527625db63b8ace540f

Anonymous sub-struct.

Expand All @@ -74,7 +64,7 @@
Member foo.


.. c:union:: @anonymous_22cf17aa0fa6d83246282a58013db249
.. c:union:: @anonymous_69382278a84175c1cbff40d522114b38

Anonymous sub-union.

Expand Down
12 changes: 0 additions & 12 deletions test/c/variable.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
#include <stdbool.h>

/**
* This is a variable document.
*/
static int sheesh;

/**
* Retain bool instead of using _Bool.
*/
static bool convert_bool;

/**
* Also convert _Bool to bool.
*/
static _Bool convert_Bool;

/**
* function pointer variable
*/
Expand Down
10 changes: 0 additions & 10 deletions test/c/variable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@
This is a variable document.


.. c:var:: static bool convert_bool

Retain bool instead of using _Bool.


.. c:var:: static bool convert_Bool

Also convert _Bool to bool.


.. c:var:: int (*function_pointer_variable)(int *param_name_ignored)

function pointer variable
Expand Down
6 changes: 0 additions & 6 deletions test/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

from hawkmoth.util import compiler

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

Expand All @@ -31,10 +29,6 @@
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None

# -- Options for Hawkmoth ----------------------------------------------------
# https://jnikula.github.io/hawkmoth/dev/extension.html#configuration

hawkmoth_clang = compiler.get_include_args()

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
Expand Down
5 changes: 0 additions & 5 deletions test/cpp/function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
Foo function.


.. cpp:function:: bool boolean(bool bar, bool baz)

Bool function.


.. cpp:function:: int no_parameters(void)

No parameters.
Expand Down
16 changes: 3 additions & 13 deletions test/cpp/struct.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@
member


.. cpp:member:: public bool bool_member

bool member


.. cpp:member:: public bool _Bool_member

_Bool member


.. cpp:member:: public int array_member[5]

array member
Expand Down Expand Up @@ -49,7 +39,7 @@
foo next


.. cpp:struct:: @anonymous_a6168a23d6840e8919ade5661a307607
.. cpp:struct:: @anonymous_7bf120438d254a91e1275b973de6a0eb

Anonymous struct documentation.

Expand All @@ -64,7 +54,7 @@
Named struct.


.. cpp:struct:: @anonymous_0a4d6f0b47cde0e9872b6dbde2ad1c1a
.. cpp:struct:: @anonymous_a63d10331be1a527625db63b8ace540f

Anonymous sub-struct.

Expand All @@ -74,7 +64,7 @@
Member foo.


.. cpp:union:: @anonymous_22cf17aa0fa6d83246282a58013db249
.. cpp:union:: @anonymous_69382278a84175c1cbff40d522114b38

Anonymous sub-union.

Expand Down
10 changes: 0 additions & 10 deletions test/cpp/variable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@
This is a variable document.


.. cpp:var:: static bool convert_bool

Retain bool instead of using _Bool.


.. cpp:var:: static bool convert_Bool

Also convert _Bool to bool.


.. cpp:var:: int (*function_pointer_variable)(int *param_name_ignored)

function pointer variable
Expand Down
6 changes: 0 additions & 6 deletions test/testenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@
import pytest
import strictyaml

from hawkmoth.util import compiler

testext = '.yaml'
testdir = os.path.dirname(os.path.abspath(__file__))
rootdir = os.path.dirname(testdir)

_clang_include_args = compiler.get_include_args()

sys.path.insert(0, rootdir)

class Directive:
Expand Down Expand Up @@ -49,8 +45,6 @@ def get_directive_string(self):
def get_clang_args(self):
clang_args = []

clang_args.extend(_clang_include_args.copy())

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

return clang_args
Expand Down
Loading