Skip to content

test(manifest): add comprehensive unit tests for test configuration parsing#1266

Open
ZainabTravadi wants to merge 2 commits intofortran-lang:mainfrom
ZainabTravadi:test-manifest-clean
Open

test(manifest): add comprehensive unit tests for test configuration parsing#1266
ZainabTravadi wants to merge 2 commits intofortran-lang:mainfrom
ZainabTravadi:test-manifest-clean

Conversation

@ZainabTravadi
Copy link
Copy Markdown
Contributor

@ZainabTravadi ZainabTravadi commented Mar 22, 2026

Closes #1267

Summary

Add comprehensive unit tests for new_test parsing in the manifest module.

The current test suite validates basic success/failure cases but does not
fully verify parsed field values or default behavior. This PR strengthens
coverage by asserting actual parsed outputs and edge cases.

Changes

Added three new tests:

  • test_test_fullparse

    • Verifies parsing of all supported fields:
      • name
      • source-dir
      • main
      • link
      • dependencies
    • Asserts correct values and allocation behavior
  • test_test_defaults

    • Verifies default values when optional fields are omitted:
      • source-dir = "test"
      • main = "main.f90"
  • test_test_invalid_name

    • Ensures invalid test names are rejected
    • Asserts error is raised with meaningful message

Why this matters

These tests establish a reliable baseline for test configuration parsing,
which is directly relevant to upcoming improvements in manifest handling.

They also improve confidence in:

  • default value behavior
  • error handling
  • parsing correctness

Scope

  • No changes to implementation
  • Test-only additions
  • Fully backward compatible

Copilot AI review requested due to automatic review settings March 22, 2026 09:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR strengthens the manifest module’s unit coverage around parsing [[test]] entries (new_test), aiming to validate parsed values, defaults, and invalid-name handling.

Changes:

  • Adds new unit tests covering full-field parsing, defaulting behavior, and invalid test names.
  • Refactors a few existing test lines for formatting/readability.
  • Updates the test_valid_manifest TOML fixture for source-dir (noted as a behavioral change in the test input).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

end if

if (index(parse_error%message, 'name must be composed only of') <= 0) then
call test_failed(error, 'Expected invalid-name phrase in error message')
Copy link

Copilot AI Mar 22, 2026

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
& '[''library'']', &
& 'source-dir = """', &
& 'lib""" # comment', &
& 'source-dir = "lib" # comment', &
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test_valid_manifest fixture used to exercise TOML multiline basic string parsing for source-dir (with closing delimiter followed by a comment). Collapsing it to a single-line string drops that coverage and isn’t mentioned in the PR description; consider keeping the multiline-string case (or adding a dedicated test) if it’s still supported/important.

Copilot uses AI. Check for mistakes.
& 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), &
Copy link

Copilot AI Mar 22, 2026

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 duplicated test- 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 like test-fullparse for consistency.

Suggested change
& new_unittest("test-test-fullparse", test_test_fullparse), &
& new_unittest("test-fullparse", test_test_fullparse), &

Copilot uses AI. Check for mistakes.
call test_failed(error, 'Expected dependencies to be parsed and allocated')
return
end if

Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_test_fullparse sets up a dependency (dummydep with a path) but only asserts that test%dependency is allocated. To match the stated goal of verifying parsed field values, this test should also assert the dependency count and key fields (e.g., that dummydep exists and its path was parsed correctly).

Suggested change
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 uses AI. Check for mistakes.
…erage

- Add assertions for dependency count and parsed values
- Ensure correct handling of character fields (no string_t usage)
- Improve validation in fullparse test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve test coverage for test manifest parsing (new_test)

2 participants