-
Notifications
You must be signed in to change notification settings - Fork 405
Module testing #1255
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
Open
phlptp
wants to merge
30
commits into
CLIUtils:main
Choose a base branch
from
phlptp:module_testing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Module testing #1255
Changes from 22 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
03e897b
test for using CLI11 in a module
phlptp 9f5e375
try to update some code to support inclusion in C++ modules
phlptp 818757c
style: pre-commit.ci fixes
pre-commit-ci[bot] 61d673e
update cmake standard used for some tests
phlptp c5a0408
more tweaks
phlptp 42f2833
try slightly different definition for string constants
phlptp fa2347d
style: pre-commit.ci fixes
pre-commit-ci[bot] 4f89361
update some docs and copyright notices on code
phlptp 2006cf1
remove duplicate line
phlptp cb6350a
style: pre-commit.ci fixes
pre-commit-ci[bot] 759ba3b
update the testing command for the module test
phlptp 16f9d4a
style: pre-commit.ci fixes
pre-commit-ci[bot] 21bd7b4
update the ctest command for module testing
phlptp d4d99b6
style: pre-commit.ci fixes
pre-commit-ci[bot] 88156f4
update the tests
phlptp 2a9533c
style: pre-commit.ci fixes
pre-commit-ci[bot] e4035ae
change to ninja generator for test
phlptp e1268c5
try using an action to get gcc 15
phlptp 75e0a18
update some tests
phlptp dd8ca49
add ninja install
phlptp 6c43ac2
style: pre-commit.ci fixes
pre-commit-ci[bot] d171471
update to support cmake 4.2
phlptp 7fd46cb
Apply suggestions from code review
phlptp a078faa
style: pre-commit.ci fixes
pre-commit-ci[bot] 34dd3ff
Merge branch 'main' into module_testing
phlptp f4ab712
try making the CLI11 module code changes dependent on C++17 for compi…
phlptp 18f9850
try with static
phlptp a2148d1
style: pre-commit.ci fixes
pre-commit-ci[bot] eb6800a
more code cleanup
phlptp b973307
style: pre-commit.ci fixes
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| cmake_minimum_required(VERSION 3.14...4.2) | ||
|
|
||
| project(CLI11-module-test) | ||
|
|
||
| include(CTest) | ||
|
|
||
| if(CLI11_DIR) | ||
| set(CMAKE_PREFIX_PATH ${CLI11_DIR}) | ||
| endif() | ||
|
|
||
| set(CMAKE_CXX_STANDARD 23) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be 20 as well? |
||
| # Test the CLI11 CMake package config | ||
| find_package(CLI11 2.5 REQUIRED) | ||
|
|
||
| # Test the target | ||
| add_executable(module-test module_test.cpp) | ||
|
|
||
| target_sources(module-test PUBLIC FILE_SET cmodule TYPE CXX_MODULES FILES cmodule.ixx) | ||
|
|
||
| target_link_libraries(module-test CLI11::CLI11) | ||
| target_compile_definitions(module-test PUBLIC -DCLI11_MODULE=1) | ||
| target_compile_options(module-test PUBLIC -fmodules-ts) | ||
|
|
||
| add_test(NAME module-test1 COMMAND module-test one) | ||
| set_property(TEST module-test1 PROPERTY PASS_REGULAR_EXPRESSION "OK: export module") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2024 scivision | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // Copyright (c) 2024 scivision | ||
| // Copyright (c) 2025 University of Cincinnati, developed by Henry Schreiner | ||
| // under NSF AWARD 1414736 and by the respective contributors. | ||
| // All rights reserved. | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| // modified from https://github.com/iTrooz/CppModules/blob/cli11 for use in CLI11 tests | ||
|
|
||
| module; | ||
|
|
||
| #include <CLI/CLI.hpp> | ||
|
|
||
| export module cmodule; | ||
|
|
||
| export void foo(CLI::App *app) {} | ||
|
|
||
| export int add(int a, int b) { return a + b; } | ||
|
|
||
| export int subtract(int a, int b) { return a - b; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // Copyright (c) 2024 scivision | ||
| // Copyright (c) 2025 University of Cincinnati, developed by Henry Schreiner | ||
| // under NSF AWARD 1414736 and by the respective contributors. | ||
| // All rights reserved. | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| // modified from https://github.com/iTrooz/CppModules/blob/cli11 for use in CLI11 tests | ||
|
|
||
| #include <cassert> | ||
| #include <cstdio> | ||
| #include <cstdlib> | ||
|
|
||
| import cmodule; | ||
|
|
||
| int main() { | ||
| int a = 1; | ||
| int b = 2; | ||
|
|
||
| int absum = add(a, b); | ||
| int abdif = subtract(a, b); | ||
|
|
||
| assert(a + b == absum); | ||
| assert(a - b == abdif); | ||
|
|
||
| // used this instead of <iostream> to work with older compilers that may choke on <iostream> implicit includes | ||
| printf("OK: export module\n"); | ||
|
|
||
| return EXIT_SUCCESS; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.