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

Added cmake tests that prevents people from changing message datatypes #337

Merged
merged 23 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
87d4682
Added cmake tests for Message Structures
yash-ni Jan 9, 2024
c9a9f24
Updated github workflows
yash-ni Jan 9, 2024
b0ab240
Corrected wrong meesage_metadata path
yash-ni Jan 9, 2024
e25bb37
Checking github workflows by changing structures
yash-ni Jan 9, 2024
9e84f67
Reverting changes
yash-ni Jan 9, 2024
4932e01
Added MessageElementMetadata
yash-ni Jan 10, 2024
b7dc903
Updated Building.md
yash-ni Jan 10, 2024
3dcd66e
Added exported function checks
yash-ni Jan 12, 2024
a7c476b
Added functionality to throw warning if user adds a new exported func…
yash-ni Jan 12, 2024
af2bad1
Merge branch 'master' of https://github.com/ni/grpc-labview into capi…
yash-ni Jan 12, 2024
a50fc6e
Updated exported function list
yash-ni Jan 12, 2024
ba1324f
Renamed some variables and replaced os.path with pathlib
yash-ni Jan 17, 2024
58bb332
Fixed pathlib error
yash-ni Jan 17, 2024
6624d5c
Probably fixed weird subprocess bug
yash-ni Jan 17, 2024
96d9b91
Added python virtual environment
yash-ni Jan 17, 2024
fa8152f
Fixed /bin/sh bug
yash-ni Jan 17, 2024
4352bff
Updated github windows workflows to print CMakeTests logs
yash-ni Jan 18, 2024
eb74d3d
Removed extra new lines from logs
yash-ni Jan 18, 2024
82c423f
Modified github workflows to print CMakeTest logs
yash-ni Jan 18, 2024
74c891b
Updated linux print logs to exit instead of throwing error
yash-ni Jan 18, 2024
91fa9eb
Updated folder in linux workflows name
yash-ni Jan 18, 2024
6c2a3e3
Corrected formatting for linux
yash-ni Jan 18, 2024
9f82f46
Merge branch 'master' into capi-changes
yash-ni Jan 18, 2024
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: 1 addition & 1 deletion .github/workflows/windows_x86_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- name: Create Build Environment
run: mkdir ${{runner.workspace}}\grpc-labview\build

yash-ni marked this conversation as resolved.
Show resolved Hide resolved
- name: Configure CMake
working-directory: ${{runner.workspace}}\grpc-labview\build
run: cmake -G "Visual Studio 16 2019" -A Win32 ..
Expand Down
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}" "./src" "./third_party/grpc" "
#----------------------------------------------------------------------
# LabVIEW support for grpc and protobuf
#----------------------------------------------------------------------

add_custom_target(Detect_MessageMetadata_Structural_Changes
yash-ni marked this conversation as resolved.
Show resolved Hide resolved
COMMAND ${CMAKE_COMMAND} -E echo "Running MessageMetadata structure test.py ..."
yash-ni marked this conversation as resolved.
Show resolved Hide resolved
COMMAND python -m pip install -r ${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeTests/requirements.txt
COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeTests/run_test.py
yash-ni marked this conversation as resolved.
Show resolved Hide resolved
RESULT_VARIABLE shell_command_result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

add_library(labview_grpc_server SHARED
src/grpc_client.cc
src/grpc_server.cc
Expand Down Expand Up @@ -180,3 +189,9 @@ target_link_libraries(test_server
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})

add_dependencies(labview_grpc_server Detect_MessageMetadata_Structural_Changes)
add_dependencies(labview_grpc_generator Detect_MessageMetadata_Structural_Changes)
add_dependencies(test_client Detect_MessageMetadata_Structural_Changes)
add_dependencies(test_server Detect_MessageMetadata_Structural_Changes)
add_dependencies(example_client Detect_MessageMetadata_Structural_Changes)
1 change: 1 addition & 0 deletions docs/Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ To prepare for cmake + Microsoft Visual C++ compiler build
- Install Visual Studio 2019 (Visual C++ compiler will be used).
- Install [Git](https://git-scm.com/).
- Install [CMake](https://cmake.org/download/).
- Install [Python 3.7 or Higher](https://www.python.org/downloads/).


#### Building 64-bit
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeTests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exported_function_list.json
1 change: 1 addition & 0 deletions tests/CMakeTests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest
yash-ni marked this conversation as resolved.
Show resolved Hide resolved
27 changes: 27 additions & 0 deletions tests/CMakeTests/run_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import subprocess
import sys
import os

def run_tests():
message_structures_test_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "tests/message_structure_test.py")
exported_functions_test_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "tests/exported_functions_test.py")
exported_functions_addition_test_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "tests/exported_functions_addition_test.py")

# Check the exit code
result_message_structure = subprocess.run(["python", "-m", "pytest", message_structures_test_path, "-vv"])
if result_message_structure.returncode != 0:
print(f"Message structural tests failed with exit code {result_message_structure.returncode}. Exiting.")
sys.exit(result_message_structure.returncode)
result_exported_functions = subprocess.run(["python", "-m", "pytest", exported_functions_test_path, "-vv"])
if result_exported_functions.returncode != 0:
print(f"Function structural tests failed with exit code {result_exported_functions.returncode}. Exiting.")
sys.exit(result_exported_functions.returncode)
result_exported_functions_addition = subprocess.run(["python", exported_functions_addition_test_path])
if result_exported_functions_addition.returncode != 0:
print(f"Function structural tests failed with exit code {result_exported_functions_addition.returncode}. Exiting.")
sys.exit(result_exported_functions_addition.returncode)

print("All structural tests passed.")

if __name__ == "__main__":
run_tests()
Loading
Loading