Skip to content

Support parsing of args field in [[test]] manifest configuration #1275

@ZainabTravadi

Description

@ZainabTravadi

Description

Problem

Currently, [[test]] entries in fpm.toml do not support specifying command-line arguments for test executables.

The existing manifest parsing logic in src/fpm/manifest/test.f90 only allows a limited set of fields (e.g., name, source-dir, main, dependencies, link). Any additional fields are rejected by the parser.

This makes it difficult to define parameterized tests directly in the manifest, and users must rely on external scripts or hardcoded behavior inside test programs.


Motivation

Many real-world test scenarios require passing arguments to test executables (e.g., input files, flags, modes). Modern build systems typically allow such configuration declaratively.

Adding support for an args field would improve flexibility while keeping the change minimal and backward compatible.


Proposed Change

Introduce an optional args field in [[test]] entries:

[[test]]
name = "example"
args = ["--input", "file.txt"]
  • The field should be parsed as an array of strings
  • It should be stored in test_config_t
  • The field should be optional and not affect existing behavior

This issue focuses only on manifest parsing support. Integration with test execution can be handled separately.


Scope

  • Extend test_config_t to include args(:)
  • Update new_test to parse the field
  • Add validation to ensure it is an array of strings
  • Add unit tests for valid and invalid cases

Notes

This is intended as a small, incremental improvement aligned with existing manifest parsing patterns.

Possible Solution

A possible implementation would involve:

  • Extending test_config_t with:

    character(:), allocatable :: args(:)
  • Updating the new_test subroutine in test.f90 to:

    • Parse the args field using existing helper utilities (e.g., string array parsing)
    • Validate that the field is an array of strings
    • Ensure backward compatibility when the field is absent
  • Updating the allowlist of accepted keys to include "args"

  • Adding regression tests in test_manifest.f90 covering:

    • Valid array input
    • Missing field
    • Invalid (non-array) input

Additional Information

This change is intentionally scoped to manifest parsing only. Execution-level support (passing arguments to test commands) can be introduced in a follow-up change to keep the implementation modular and reviewable.

This also aligns with ongoing efforts to improve the flexibility of the test configuration in fpm.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions