Skip to content

tests: Don't specify planned number of tests up-front - #6794

Merged
smcv merged 5 commits into
flatpak:mainfrom
smcv:done-testing
Aug 21, 2026
Merged

smcv merged 5 commits into
flatpak:mainfrom
smcv:done-testing

Conversation

@smcv

@smcv smcv commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator
  • tests: Track and emit TAP test numbers in shell script tests

    This will help us to emit correct TAP syntax, without having to always
    declare up-front how many tests we are going to run.

  • tests: Add a function to declare the "plan", instead of direct echo

    This is approximately the equivalent of 'plan' in Perl Test::More:
    it announces how many tests we plan to run.

  • tests: At the end of each test, explicitly log that we have finished

    This is the equivalent of the function of the same name in Perl's
    Test::More. If we already emitted a test plan, it asserts that the
    number of tests we planned to do equals the number we actually did.

    If not, it assumes that however many tests we have done, that's all of
    the tests that we intend to do - this can be useful in test scripts
    that routinely increase in length, like test-run.sh which is becoming
    rather long (and has frequent conflicts for the "plan" line when we
    cherry-pick new test coverage to older branches).

  • tests: Consistently Use the "no plan" style for TAP tests

    Instead of announcing ahead of time how many tests will be run, just
    log 1..32 or similar at the end, from the done_testing function.

    This should go some way towards preventing unnecessary cherry-pick
    conflicts when tests added to this script get backported.

    Resolves: Cherry-picking new test coverage usually causes conflicts #6793

  • tests: Drop plan_tests function, no longer used


This is going to be a bit annoying for backports to stable-branches at first, but no worse than the current situation. We could backport these tests improvements (they only touch tests and not production code, and are not too intrusive), or we could accept that 1.18.x is going to continue to be a bit annoying but at least backporting from 1.21.x to 1.20.x will be easier.

Comment thread tests/libtest.sh Fixed
@smcv

smcv commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

I think it would also be good to split at least the worst offenders - test-run.sh and test-repo.sh - into more, smaller scripts. But if we are going to make this change, I think it probably makes more sense to do it before splitting?

@swick

swick commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Yup, sounds all good to me. I would prefer to be consistent and just never use plan_tests then.

@smcv
smcv marked this pull request as draft August 21, 2026 14:19
@smcv smcv changed the title Formalize TAP output from shell scripts, don't require always specifying number of tests up-front tests: Don't specify planned number of tests up-front Aug 21, 2026
@smcv

smcv commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

I would prefer to be consistent and just never use plan_tests then.

Updated accordingly

@smcv
smcv marked this pull request as ready for review August 21, 2026 14:20
smcv added 5 commits August 21, 2026 15:21
This will help us to emit correct TAP syntax, without having to always
declare up-front how many tests we are going to run.

Signed-off-by: Simon McVittie <[email protected]>
This is approximately the equivalent of 'plan' in Perl Test::More:
it announces how many tests we plan to run.

Signed-off-by: Simon McVittie <[email protected]>
This is the equivalent of the function of the same name in Perl's
Test::More. If we already emitted a test plan, it asserts that the
number of tests we planned to do equals the number we actually did.

If not, it assumes that however many tests we have done, that's all of
the tests that we intend to do - this can be useful in test scripts
that routinely increase in length, like test-run.sh which is becoming
rather long (and has frequent conflicts for the "plan" line when we
cherry-pick new test coverage to older branches).

Signed-off-by: Simon McVittie <[email protected]>
Instead of announcing ahead of time how many tests will be run, just
log 1..32 or similar at the end, from the done_testing function.

This should go some way towards preventing unnecessary cherry-pick
conflicts when tests added to this script get backported.

Resolves: flatpak#6793
Signed-off-by: Simon McVittie <[email protected]>
@smcv
smcv added this pull request to the merge queue Aug 21, 2026
Merged via the queue into flatpak:main with commit f0ce131 Aug 21, 2026
11 checks passed
@smcv
smcv deleted the done-testing branch August 21, 2026 15:43
@smcv

smcv commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

Oops, this wasn't quite right. Followup in #6796

@swick swick mentioned this pull request Aug 27, 2026
smcv added a commit to smcv/flatpak-builder that referenced this pull request Sep 15, 2026
Similar to
flatpak/flatpak@b1fdf6c
this makes it more obvious where the boundary between test-cases is,
and similar to flatpak/flatpak#6794 it avoids
needing to declare up-front how many tests we plan to run (which makes
conflicts inevitable if we add more than one test to the same script).

Signed-off-by: Simon McVittie <[email protected]>
smcv added a commit to smcv/flatpak-builder that referenced this pull request Sep 15, 2026
Similar to
flatpak/flatpak@b1fdf6c
this makes it more obvious where the boundary between test-cases is,
and similar to flatpak/flatpak#6794 it avoids
needing to declare up-front how many tests we plan to run (which makes
conflicts inevitable if we add more than one test to the same script).

Signed-off-by: Simon McVittie <[email protected]>
bbhtt pushed a commit to flatpak/flatpak-builder that referenced this pull request Sep 15, 2026
Similar to
flatpak/flatpak@b1fdf6c
this makes it more obvious where the boundary between test-cases is,
and similar to flatpak/flatpak#6794 it avoids
needing to declare up-front how many tests we plan to run (which makes
conflicts inevitable if we add more than one test to the same script).

Signed-off-by: Simon McVittie <[email protected]>
bbhtt pushed a commit to flatpak/flatpak-builder that referenced this pull request Sep 15, 2026
Similar to
flatpak/flatpak@b1fdf6c
this makes it more obvious where the boundary between test-cases is,
and similar to flatpak/flatpak#6794 it avoids
needing to declare up-front how many tests we plan to run (which makes
conflicts inevitable if we add more than one test to the same script).

Signed-off-by: Simon McVittie <[email protected]>
bbhtt pushed a commit to flatpak/flatpak-builder that referenced this pull request Sep 15, 2026
Similar to
flatpak/flatpak@b1fdf6c
this makes it more obvious where the boundary between test-cases is,
and similar to flatpak/flatpak#6794 it avoids
needing to declare up-front how many tests we plan to run (which makes
conflicts inevitable if we add more than one test to the same script).

Signed-off-by: Simon McVittie <[email protected]>
bbhtt pushed a commit to flatpak/flatpak-builder that referenced this pull request Sep 15, 2026
Similar to
flatpak/flatpak@b1fdf6c
this makes it more obvious where the boundary between test-cases is,
and similar to flatpak/flatpak#6794 it avoids
needing to declare up-front how many tests we plan to run (which makes
conflicts inevitable if we add more than one test to the same script).

Signed-off-by: Simon McVittie <[email protected]>
bbhtt pushed a commit to flatpak/flatpak-builder that referenced this pull request Sep 15, 2026
Similar to
flatpak/flatpak@b1fdf6c
this makes it more obvious where the boundary between test-cases is,
and similar to flatpak/flatpak#6794 it avoids
needing to declare up-front how many tests we plan to run (which makes
conflicts inevitable if we add more than one test to the same script).

Signed-off-by: Simon McVittie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cherry-picking new test coverage usually causes conflicts

3 participants