Skip to content

t/harness - rework App::Prove::State setup to not warn and use customizable state file #20967

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

Merged
merged 1 commit into from
Mar 28, 2023

Conversation

demerphq
Copy link
Collaborator

@demerphq demerphq commented Mar 25, 2023

Currently we only store state if we are running parallel tests, so if you run the tests in series we do not store data on how long they took, and we can't use that information in a follow up parallel test run.

We also do not allow the state file to be customized to be outside of the repo, so git clean -dfx wipes it. This means you can't keep your test data over time, which can be a bit annoying.

We also currently construct the state object twice during setup, resulting in two (useless) warnings when the state file is missing, which also doubles the time to set up the tests because the yaml file gets read twice, and not very efficiently either.

This patch changes the logic so that we initialize the state object only once during startup, and we use the state file if we are going to run tests, parallel or not, provided the user does not explicitly disable it (see below). The order that tests are run is affected only when the tests are run in parallel.

It also allows the user to specify where the state file should live, with the $ENV{PERL_TEST_STATE_FILE} environment variable, which can be set to 0 or the empty string to disable use of the state file if needed.

We also take care to silence the warning about an empty state file, except in the case where the user has overriden the file name with the $ENV{PERL_TEST_STATE_FILE}.

Lastly this patch disables loading the state data /at all/, when the dump_tests option is invoked. There is no need nor point to load the state data when we are simply going to dump out the list of tests we will run.

@demerphq demerphq changed the title t/harness - rework App::Prove::State setup to not warn and use custom… t/harness - rework App::Prove::State setup to not warn and use customizable state file Mar 25, 2023
…izable state file

Currently we only store state if we are running parallel tests, so if
you run the tests in series we do not store data on how long they took,
and we can't use that information in a follow up parallel test run.

We also do not allow the state file to be customized to be outside of
the repo, so git clean -dfx wipes it. This means you can't keep your
test data over time, which can be a bit annoying.

We also currently construct the state object twice during setup,
resulting in two (useless) warnings when the state file is missing,
which also doubles the time to set up the tests because the yaml file
gets read twice, and not very efficiently either.

This patch changes the logic so that we initialize the state object only
once during startup, and we use the state file if we are going to run
tests, parallel or not, provided the user does not explicitly disable it
(see below). The order that tests are run is affected only when the
tests are run in parallel.

It also allows the user to specify where the state file should live,
with the $ENV{PERL_TEST_STATE_FILE} environment variable, which can be
set to 0 or the empty string to disable use of the state file if needed.

We also take care to silence the warning about an empty state file,
except in the case where the user has overriden the file name with the
$ENV{PERL_TEST_STATE_FILE}.

Lastly this patch disables loading the state data /at all/, when
the dump_tests option is invoked. There is no need nor point to
load the state data when we are simply going to dump out the list
of tests we will run.
@demerphq demerphq force-pushed the yves/test_harness_state_init_fixes branch from 24ec3b6 to e411340 Compare March 28, 2023 09:59
@demerphq demerphq merged commit da545c2 into blead Mar 28, 2023
@demerphq demerphq deleted the yves/test_harness_state_init_fixes branch March 28, 2023 13:50
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.

2 participants