This should have been in commit
06c47695fc. The tests that use this
module did not fail because an import failure is assumed to be caused
by a missing dependency, not a genuine bug.
This is a preparatory step to improving the deduplication of queries.
It also makes possible future improvements to config validation and
help usage output.
* Wrap all conditional loads in `BEGIN {}` to be closer to the
behavior of `use`.
* Add missing `Test::Warnings`, `HTTP::Request` loads.
* Sort by module name, except load `Test::More` first and
`Test::Warnings` immediately after to maximize checking
effectiveness.
* Return truthy from `eval` block to prevent the `or` case from
executing if the loaded module does not have a final truthy
statement. (Except for `ddclient` because we want to test that it
does have a final truthy statement.)
All log output goes to stderr, so turning on `debug` or `verbose` will
not interfere with TAP. A better way to debug is to add the following
to whatever scope you think is appropriate:
local $ddclient::globals{debug} = 1;
local $ddclient::globals{verbose} = 1;
Status is not configuration so it doesn't belong in `%config`.
`wantip`, `wantipv4`, and `wantipv6` are still passed along in
`%config` because `group_hosts_by` needs access to them like other
settings.
Currently the semantics of recap variables are that values are updated
in `%config` and propagate to `%recap`. Before this commit,
`warned-min-interval` and `warned-min-error-interval` were set in
`%recap` instead of `%config`, meaning if they followed the semantics
they would be overwritten or deleted when synced with `%config`. Now
the values are set in `%config` to match the behavior of other recap
variables.
When a legacy protocol implementation returns, move its `status` and
`ip` results to the new `status-ipv4` and `ipv4` (or `status-ipv6` and
`ipv6`) properties.
Also remove the now-unused `status` variable definition, and remove
`ip` from the recap.
* Delete values from `$config{$h}` and `$recap{$h}` when resetting
values (as opposed to setting a falsy value).
* Delete values from `$config{$h}` and `$recap{$h}` when they are no
longer needed.
This is mostly done to improve the tests in `t/update_nics.pl`.
This is mostly to simplify tests, but it also improves readability.
The infrastructure changes in this commit also make it possible to
introduce a new `url` variable that defaults to `opt('server', $h)`
concatenated with `opt('script', $h)` so that we can start migrating
away from those user-unfriendly variables.
The `opt` function falls back to global/default if the value is
undefined, even if it is explicitly set to `undef`. `group_hosts_by`
should behave the same.
Allow newlines to be in values, but stop searching for assignments
once an unescaped/unquoted newline is discovered. This is preparation
to using `parse_assignments` to process the `--options` command-line
argument, which might have embedded newlines.
The `ssl` option is a global option, not a per-host option. This
commit could instead do:
local $ddclient::globals{ssl} = 0;
but it's more straightforward to include `http://` in the `server`
option, and it tests that `server` supports the inclusion of the
scheme.