Skip to content
Open
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
4 changes: 3 additions & 1 deletion codegen/src/targets/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,9 @@ fn module_test(slug: &str, functions: &[&CompiledFunction]) -> Result<String> {
.iter()
.any(|function| matches!(function.core.output, Output::Struct(_)));
let mut writer = Writer::new();
writer.write(format_args!("{HEADER}\n\n#ifdef IMPORT_UMBRELLA\nimport ptfkit;\n#else\nimport ptfkit.{slug};\n#endif\n\n#include \"support/close_enough.h\""));
writer.write(format_args!(
"{HEADER}\n\nimport ptfkit.{slug};\n\n#include \"support/close_enough.h\""
));
if type_traits {
writer.write("\n#include <type_traits>\n\n");
} else {
Expand Down
7 changes: 7 additions & 0 deletions docs/src/contributing/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ These files have no generated-file marker and are not codegen outputs. Edit them
directly when changing test infrastructure, then run the target verification
suites. Keep the shared comparison policy consistent across targets.

The handwritten native tests `tests/support/umbrella.c` and
`tests/support/umbrella.cpp` check function and result-type access through
`<ptfkit/ptfkit.h>` and `import ptfkit`, respectively. The C test is compiled as
both C11 and C++23 and checks that all public headers can be included together.
Generated verification tests use individual source headers or modules without
repeating the suite through the umbrella.

### Adding a PTF

The assisted workflow uses the skills in `.agents/skills/`:
Expand Down
5 changes: 1 addition & 4 deletions targets/ptfkit-native/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ function(ptfkit_add_native_tests case)
PARSE_ARGV 1 arg
""
""
"SOURCES;LIBRARIES;DEFINITIONS;PROPERTIES;COMPILE_FEATURES"
"SOURCES;LIBRARIES;PROPERTIES;COMPILE_FEATURES"
)
foreach(source ${arg_SOURCES})
get_filename_component(name ${source} NAME_WE)
set(target ${case}_${name})
add_executable(${target} ${source})
target_link_libraries(${target} PRIVATE ${arg_LIBRARIES})
if(arg_DEFINITIONS)
target_compile_definitions(${target} PRIVATE ${arg_DEFINITIONS})
endif()
if(arg_PROPERTIES)
set_target_properties(${target} PROPERTIES ${arg_PROPERTIES})
endif()
Expand Down
6 changes: 5 additions & 1 deletion targets/ptfkit-native/tests/c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
file(GLOB sources CONFIGURE_DEPENDS *.c)

ptfkit_add_native_tests(c
SOURCES ${sources}
SOURCES ${sources} ../support/umbrella.c
LIBRARIES ptfkit::c
)

set_target_properties(c_umbrella PROPERTIES
C_STANDARD 11 C_STANDARD_REQUIRED ON C_EXTENSIONS OFF
)

ptfkit_add_comparator_test(C c_comparator)
10 changes: 1 addition & 9 deletions targets/ptfkit-native/tests/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
file(GLOB sources CONFIGURE_DEPENDS *.cpp)

ptfkit_add_native_tests(cpp
SOURCES ${sources}
SOURCES ${sources} ../support/umbrella.cpp
LIBRARIES ptfkit::cpp
PROPERTIES
CXX_SCAN_FOR_MODULES ON
)

ptfkit_add_native_tests(cpp_umbrella
SOURCES ${sources}
LIBRARIES ptfkit::cpp
DEFINITIONS IMPORT_UMBRELLA
PROPERTIES
CXX_SCAN_FOR_MODULES ON
)
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/ahuja1984.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.ahuja1984;
#endif

#include "support/close_enough.h"

Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/aimrun2009.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.aimrun2009;
#endif

#include "support/close_enough.h"

Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/beniaich2023.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.beniaich2023;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/chakraborty2011.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.chakraborty2011;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/clapp1978.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.clapp1978;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/cosby1984.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.cosby1984;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/dharumarajan2019.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.dharumarajan2019;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/ferrerjulia2004.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.ferrerjulia2004;
#endif

#include "support/close_enough.h"

Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/gunarathna2019.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.gunarathna2019;
#endif

#include "support/close_enough.h"

Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/hodnett2002.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.hodnett2002;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/jabro1992.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.jabro1992;
#endif

#include "support/close_enough.h"

Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/lal1979.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.lal1979;
#endif

#include "support/close_enough.h"

Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/li2007.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.li2007;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/mayr1999.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.mayr1999;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/oosterveld1980.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.oosterveld1980;
#endif

#include "support/close_enough.h"

Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/pidgeon1972.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.pidgeon1972;
#endif

#include "support/close_enough.h"

Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/puckett1985.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.puckett1985;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/rawls1982.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.rawls1982;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/saxton2006.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.saxton2006;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/tiwary2014.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.tiwary2014;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/varallyai1982.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.varallyai1982;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/vereecken1989.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.vereecken1989;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/wang2012.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.wang2012;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/weber2020.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.weber2020;
#endif

#include "support/close_enough.h"
#include <type_traits>
Expand Down
4 changes: 0 additions & 4 deletions targets/ptfkit-native/tests/cpp/zhao2016.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/* @generated by ptfkit-codegen; DO NOT EDIT. */

#ifdef IMPORT_UMBRELLA
import ptfkit;
#else
import ptfkit.zhao2016;
#endif

#include "support/close_enough.h"

Expand Down
5 changes: 5 additions & 0 deletions targets/ptfkit-native/tests/cpp_fallback/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
file(GLOB sources CONFIGURE_DEPENDS ../c/*.c)
list(APPEND sources "${CMAKE_CURRENT_SOURCE_DIR}/../support/umbrella.c")

set_source_files_properties(
${sources}
Expand All @@ -12,3 +13,7 @@ ptfkit_add_native_tests(cpp_fallback
)

ptfkit_add_comparator_test(CXX cpp_comparator)

set_target_properties(cpp_fallback_umbrella PROPERTIES
CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF
)
11 changes: 11 additions & 0 deletions targets/ptfkit-native/tests/support/umbrella.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <ptfkit/ptfkit.h>

#include "close_enough.h"

int main(void) {
const saxton2006_ptf_result result = calc_ptf_saxton2006(0.88, 0.05, 2.5);
// Expected value from specs/functions/saxton2006.yaml, table_3_sand.
assert_close(result.theta_1500, 0.05022058, 0.001, 0.0, "volumetric_water_content",
"volume_fraction", "registry", "table_3_sand");
return 0;
}
12 changes: 12 additions & 0 deletions targets/ptfkit-native/tests/support/umbrella.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import ptfkit;

#include "close_enough.h"

int main() {
const ptfkit::saxton2006::Saxton2006PTFResult result =
ptfkit::saxton2006::calc_ptf_saxton2006(0.88, 0.05, 2.5);
// Expected value from specs/functions/saxton2006.yaml, table_3_sand.
assert_close(result.theta_1500, 0.05022058, 0.001, 0.0, "volumetric_water_content",
"volume_fraction", "registry", "table_3_sand");
return 0;
}
Loading