-
Notifications
You must be signed in to change notification settings - Fork 132
test(manifest): add comprehensive unit tests for test configuration parsing #1266
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -43,8 +43,7 @@ subroutine collect_manifest(testsuite) | |||||||||||||||||||||||||||||
| & new_unittest("dependency-features-empty", test_dependency_features_empty), & | ||||||||||||||||||||||||||||||
| & new_unittest("dependency-profile-present", test_dependency_profile_present), & | ||||||||||||||||||||||||||||||
| & new_unittest("dependency-profile-absent", test_dependency_profile_absent), & | ||||||||||||||||||||||||||||||
| & new_unittest("dependency-profile-features-conflict", & | ||||||||||||||||||||||||||||||
| & test_dependency_profile_features_conflict, should_fail=.true.), & | ||||||||||||||||||||||||||||||
| & new_unittest("dependency-profile-features-conflict", test_dependency_profile_features_conflict, should_fail=.true.), & | ||||||||||||||||||||||||||||||
| & new_unittest("dependency-wrongkey", test_dependency_wrongkey, should_fail=.true.), & | ||||||||||||||||||||||||||||||
| & new_unittest("dependencies-empty", test_dependencies_empty), & | ||||||||||||||||||||||||||||||
| & new_unittest("dependencies-typeerror", test_dependencies_typeerror, should_fail=.true.), & | ||||||||||||||||||||||||||||||
|
|
@@ -73,6 +72,9 @@ subroutine collect_manifest(testsuite) | |||||||||||||||||||||||||||||
| & new_unittest("test-typeerror", test_test_typeerror, should_fail=.true.), & | ||||||||||||||||||||||||||||||
| & new_unittest("test-noname", test_test_noname, should_fail=.true.), & | ||||||||||||||||||||||||||||||
| & new_unittest("test-wrongkey", test_test_wrongkey, should_fail=.true.), & | ||||||||||||||||||||||||||||||
| & new_unittest("test-test-fullparse", test_test_fullparse), & | ||||||||||||||||||||||||||||||
| & new_unittest("test-defaults", test_test_defaults), & | ||||||||||||||||||||||||||||||
| & new_unittest("test-invalid-name", test_test_invalid_name), & | ||||||||||||||||||||||||||||||
| & new_unittest("link-string", test_link_string), & | ||||||||||||||||||||||||||||||
| & new_unittest("link-array", test_link_array), & | ||||||||||||||||||||||||||||||
| & new_unittest("link-error", test_invalid_link, should_fail=.true.), & | ||||||||||||||||||||||||||||||
|
|
@@ -86,8 +88,7 @@ subroutine collect_manifest(testsuite) | |||||||||||||||||||||||||||||
| & new_unittest("preprocess-wrongkey", test_preprocess_wrongkey, should_fail=.true.), & | ||||||||||||||||||||||||||||||
| & new_unittest("preprocessors-empty", test_preprocessors_empty, should_fail=.true.), & | ||||||||||||||||||||||||||||||
| & new_unittest("macro-parsing", test_macro_parsing, should_fail=.false.), & | ||||||||||||||||||||||||||||||
| & new_unittest("macro-parsing-dependency", & | ||||||||||||||||||||||||||||||
| & test_macro_parsing_dependency, should_fail=.false.), & | ||||||||||||||||||||||||||||||
| & new_unittest("macro-parsing-dependency", test_macro_parsing_dependency, should_fail=.false.), & | ||||||||||||||||||||||||||||||
| & new_unittest("features-demo-serialization", test_features_demo_serialization) & | ||||||||||||||||||||||||||||||
| & ] | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -124,8 +125,7 @@ subroutine test_valid_manifest(error) | |||||||||||||||||||||||||||||
| & 'source-dir = "prog"', & | ||||||||||||||||||||||||||||||
| & '[executable.dependencies]', & | ||||||||||||||||||||||||||||||
| & '[''library'']', & | ||||||||||||||||||||||||||||||
| & 'source-dir = """', & | ||||||||||||||||||||||||||||||
| & 'lib""" # comment', & | ||||||||||||||||||||||||||||||
| & 'source-dir = "lib" # comment', & | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| & '[preprocess]', & | ||||||||||||||||||||||||||||||
| & '[preprocess.cpp]', & | ||||||||||||||||||||||||||||||
| & 'suffixes = ["F90", "f90"]', & | ||||||||||||||||||||||||||||||
|
|
@@ -228,8 +228,7 @@ subroutine test_default_library(error) | |||||||||||||||||||||||||||||
| allocate(package%library) | ||||||||||||||||||||||||||||||
| call default_library(package%library) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| call check_string(error, package%library%source_dir, "src", & | ||||||||||||||||||||||||||||||
| & "Default library source-dir") | ||||||||||||||||||||||||||||||
| call check_string(error, package%library%source_dir, "src", "Default library source-dir") | ||||||||||||||||||||||||||||||
| if (allocated(error)) return | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (.not.allocated(package%library%include_dir)) then | ||||||||||||||||||||||||||||||
|
|
@@ -309,12 +308,10 @@ subroutine test_default_executable(error) | |||||||||||||||||||||||||||||
| allocate(package%executable(1)) | ||||||||||||||||||||||||||||||
| call default_executable(package%executable(1), name) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| call check_string(error, package%executable(1)%source_dir, "app", & | ||||||||||||||||||||||||||||||
| & "Default executable source-dir") | ||||||||||||||||||||||||||||||
| call check_string(error, package%executable(1)%source_dir, "app", "Default executable source-dir") | ||||||||||||||||||||||||||||||
| if (allocated(error)) return | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| call check_string(error, package%executable(1)%name, name, & | ||||||||||||||||||||||||||||||
| & "Default executable name") | ||||||||||||||||||||||||||||||
| call check_string(error, package%executable(1)%name, name, "Default executable name") | ||||||||||||||||||||||||||||||
| if (allocated(error)) return | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| call package%feature_config_t%test_serialization('test_default_executable (feature only)',error) | ||||||||||||||||||||||||||||||
|
|
@@ -872,8 +869,7 @@ subroutine test_library_empty(error) | |||||||||||||||||||||||||||||
| call new_library(library, table, error) | ||||||||||||||||||||||||||||||
| if (allocated(error)) return | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| call check_string(error, library%source_dir, "src", & | ||||||||||||||||||||||||||||||
| & "Default library source-dir") | ||||||||||||||||||||||||||||||
| call check_string(error, library%source_dir, "src", "Default library source-dir") | ||||||||||||||||||||||||||||||
| if (allocated(error)) return | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (.not.allocated(library%include_dir)) then | ||||||||||||||||||||||||||||||
|
|
@@ -1218,6 +1214,120 @@ subroutine test_test_wrongkey(error) | |||||||||||||||||||||||||||||
| end subroutine test_test_wrongkey | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| !> Parse all currently supported test fields | ||||||||||||||||||||||||||||||
| subroutine test_test_fullparse(error) | ||||||||||||||||||||||||||||||
| use fpm_manifest_test | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| !> Error handling | ||||||||||||||||||||||||||||||
| type(error_t), allocatable, intent(out) :: error | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| type(toml_table) :: table | ||||||||||||||||||||||||||||||
| type(toml_array), pointer :: children | ||||||||||||||||||||||||||||||
| type(toml_table), pointer :: child, child2 | ||||||||||||||||||||||||||||||
| integer :: stat | ||||||||||||||||||||||||||||||
| type(test_config_t) :: test | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| call new_table(table) | ||||||||||||||||||||||||||||||
| call set_value(table, 'name', 'mytest', stat) | ||||||||||||||||||||||||||||||
| call set_value(table, 'source-dir', 'src/tests', stat) | ||||||||||||||||||||||||||||||
| call set_value(table, 'main', 'prog.f90', stat) | ||||||||||||||||||||||||||||||
| call add_array(table, 'link', children, stat) | ||||||||||||||||||||||||||||||
| call set_value(children, 1, 'mylib', stat) | ||||||||||||||||||||||||||||||
| call add_table(table, 'dependencies', child, stat) | ||||||||||||||||||||||||||||||
| call add_table(child, 'dummydep', child2, stat) | ||||||||||||||||||||||||||||||
| call set_value(child2, 'path', './dummydep', stat) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| call new_test(test, table, error) | ||||||||||||||||||||||||||||||
| if (allocated(error)) return | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| call check_string(error, test%name, 'mytest', 'Test name') | ||||||||||||||||||||||||||||||
| if (allocated(error)) return | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| call check_string(error, test%source_dir, 'src/tests', 'Test source-dir') | ||||||||||||||||||||||||||||||
| if (allocated(error)) return | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| call check_string(error, test%main, 'prog.f90', 'Test main') | ||||||||||||||||||||||||||||||
| if (allocated(error)) return | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (.not.allocated(test%link)) then | ||||||||||||||||||||||||||||||
| call test_failed(error, 'Expected link list to be allocated') | ||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||
| end if | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (size(test%link) /= 1) then | ||||||||||||||||||||||||||||||
| call test_failed(error, 'Expected exactly one link library') | ||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||
| end if | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| call check_string(error, test%link(1)%s, 'mylib', 'Test link item') | ||||||||||||||||||||||||||||||
| if (allocated(error)) return | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (.not.allocated(test%dependency)) then | ||||||||||||||||||||||||||||||
| call test_failed(error, 'Expected dependencies to be parsed and allocated') | ||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||
| end if | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| if (size(test%dependency) /= 1) then | |
| call test_failed(error, 'Expected exactly one dependency to be parsed') | |
| return | |
| end if | |
| call check_string(error, test%dependency(1)%name%s, 'dummydep', & | |
| 'Test dependency name') | |
| if (allocated(error)) return | |
| call check_string(error, test%dependency(1)%path%s, './dummydep', & | |
| 'Test dependency path') | |
| if (allocated(error)) return |
Copilot
AI
Mar 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the error-message substring check fails, the test currently reports a generic message. Including parse_error%message (or at least a larger expected substring) in the failure output would make diagnosing future regressions much easier.
| call test_failed(error, 'Expected invalid-name phrase in error message') | |
| call test_failed(error, 'Expected invalid-name phrase in error message, got: '//parse_error%message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unittest name
"test-test-fullparse"has a duplicatedtest-prefix and is inconsistent with the other test-case names in this section (e.g.,test-simple,test-empty,test-defaults). Consider renaming it to something liketest-fullparsefor consistency.