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

#132 Port remaining grammar tests to C++ #134

Merged
merged 8 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
12 changes: 10 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ name: CMake
on:
push:
branches: ["main"]
paths:
- "ports/cpp/**"
- ".github/workflows/*"
mike-lischke marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
branches: ["main"]
paths:
- "ports/cpp/**"
- ".github/workflows/*"

jobs:
build:
Expand All @@ -14,8 +20,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Build Essential
run: sudo apt update && sudo apt install build-essential
- name: Install dependencies
run: |
sudo apt update
sudo apt install build-essential
- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ name: Build & Test
on:
push:
branches: [ main ]
paths-ignore: ["ports/**"]
mike-lischke marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
branches: [ main ]
paths-ignore: ["ports/**"]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion ports/cpp/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "lldb",
"request": "launch",
"name": "Debug Test",
"program": "${workspaceFolder}/build/test/${fileDirnameBasename}/antlr4-c3-test",
"program": "${workspaceFolder}/build/test/${fileDirnameBasename}/antlr4-c3-test-${fileDirnameBasename}",
"args": [],
"cwd": "${workspaceFolder}",
"preLaunchTask": "Build All"
Expand Down
2 changes: 1 addition & 1 deletion ports/cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Please see the parent [README.md](../../readme.md) for an explanation of the lib

## Requirements

- [C++ 23 standard](https://en.cppreference.com/w/cpp/23) to compile sources.
- [C++ 20 standard](https://en.cppreference.com/w/cpp/20) to compile sources.

- [ANTLRv4 C++ Runtime](https://github.com/antlr/antlr4/tree/4.13.1/runtime/Cpp) to compile sources.

Expand Down
2 changes: 1 addition & 1 deletion ports/cpp/cmake/CompileOptions.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
mike-lischke marked this conversation as resolved.
Show resolved Hide resolved
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
19 changes: 15 additions & 4 deletions ports/cpp/cmake/Testing.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
macro(define_grammar_test grammar)
get_filename_component(
ANTLR4C3_CURRENT_DIR_NAME
${CMAKE_CURRENT_LIST_DIR} NAME
)

antlr_generate(
${CMAKE_CURRENT_LIST_DIR}/${grammar}
${CMAKE_CURRENT_BINARY_DIR}
Expand All @@ -11,19 +16,25 @@ macro(define_grammar_test grammar)
${CMAKE_CURRENT_BINARY_DIR}/*.cpp
)

add_executable(${PROJECT_NAME}-test ${SOURCE})
set(
ANTLR4C3_TEST_TARGET
${PROJECT_NAME}-test-${ANTLR4C3_CURRENT_DIR_NAME}
)
mike-lischke marked this conversation as resolved.
Show resolved Hide resolved

add_executable(${ANTLR4C3_TEST_TARGET} ${SOURCE})

target_include_directories(
${PROJECT_NAME}-test PRIVATE
${ANTLR4C3_TEST_TARGET} PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_LIST_DIR}/..
)

target_link_libraries(
${PROJECT_NAME}-test PRIVATE
${ANTLR4C3_TEST_TARGET} PRIVATE
${PROJECT_NAME}
GTest::gtest_main
GTest::gmock
)

gtest_discover_tests(${PROJECT_NAME}-test)
gtest_discover_tests(${ANTLR4C3_TEST_TARGET})
endmacro()
2 changes: 2 additions & 0 deletions ports/cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ add_compile_options(-Wno-unused-parameter)

enable_testing()
add_subdirectory(expr)
add_subdirectory(whitebox)
add_subdirectory(cpp14)
1 change: 1 addition & 0 deletions ports/cpp/test/cpp14/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
define_grammar_test(CPP14.g4)
Loading
Loading