Skip to content

Commit

Permalink
Add support for Python integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simondevenish committed Nov 17, 2024
1 parent ec8030c commit 8cc9b48
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
14 changes: 10 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools",
"GitHub.vscode-github-actions"
]
"GitHub.vscode-github-actions",
"ms-python.python"
],
"settings": {
"python.defaultInterpreterPath": "/venv/bin/python",
"python.venvPath": "/venv",
"terminal.integrated.defaultProfile.linux": "bash"
}
}
},
"postCreateCommand": "cmake -S . -B build",
"postCreateCommand": "python3 -m venv /venv && source /venv/bin/activate && pip install --no-cache-dir pytest pyyaml && cmake -S . -B build",
"remoteUser": "root"
}
}
14 changes: 13 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
ENV CC=/usr/bin/gcc
ENV CXX=/usr/bin/g++
ENV VIRTUAL_ENV=/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# Install core development tools and dependencies
RUN apt-get update && apt-get install -y \
Expand All @@ -22,6 +24,7 @@ RUN apt-get update && apt-get install -y \
zlib1g-dev \
python3 \
python3-pip \
python3-venv \
python3-yaml \
git \
xxd \
Expand All @@ -42,6 +45,12 @@ RUN gcc --version && g++ --version && cmake --version
# Set the working directory
WORKDIR /usr/src/SubZero

# Create and activate a Python virtual environment
RUN python3 -m venv $VIRTUAL_ENV

# Install Python dependencies into the virtual environment
RUN pip install --no-cache-dir pytest pyyaml

# Copy the entire project into the container, excluding files in .dockerignore
COPY . .

Expand All @@ -51,11 +60,14 @@ RUN chmod +x tools/gen-version-file \
tools/gen-test-proto \
tools/fix/fixdialectc

# Add virtual environment activation to bashrc
RUN echo "source $VIRTUAL_ENV/bin/activate" >> ~/.bashrc

# Build the project using CMake with verbose output
RUN cmake -S . -B build -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON
RUN cmake --build build

# Run tests
# Run C++ tests
RUN cd build && ctest --output-on-failure

# Default command when the container is run
Expand Down
2 changes: 1 addition & 1 deletion tools/fix/fixdialectc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ parser.add_argument('--source-path', help="output source path")

args = parser.parse_args()

data = yaml.load(open(args.input_file, 'r'))
data = yaml.load(open(args.input_file, 'r'), Loader=yaml.SafeLoader)

name = data["name"]
base_protocol = data["base_protocol"]
Expand Down

0 comments on commit 8cc9b48

Please sign in to comment.