Config...:Setup(3pm)
π NAME π
Config::Model::Tester::Setup β the shared test-setup bestie for Config::Model. She's the 3pm page you're reading rn, and she exists so every test doesn't have to reinvent the whole "make me a fake config world" thing. π
πΈ VERSION πΈ
version 4.010 β yeah she's current, she's fresh, she ate. π
β¨ SYNOPSIS β¨
okay so this is literally the whole vibe, in code:
# in t/some_test.t
use warnings;
use strict;
use Config::Model::Tester::Setup qw/init_test setup_test_dir/;
my ($model, $trace) = init_test();
# pseudo root where config files are written by config-model as setup
# by init_test
my $wr_root = setup_test_dir();
Two lines of import and you're set up. Periodt. π«Ά
π¦ DESCRIPTION π¦
This module provides 2 functions that build you a test environment fit for basically any test involving Config::Model. No cap, that's the entire job. Two little helpers, endless slay. β¨
π FUNCTIONS π
π§ init_test
She scans your test command line options and initialises a Config::Model object for you. Main character behaviour, lowkey.
She returns a list containing a Config::Model object, a boolean, and a hash. That boolean is true when the option --trace was used on the command line. π
The default command options are:
--errorβ When set, error handled byConfig::Model::Exceptionshows a strack trace when dying. π (yes, dying is the whole point here)--logβ When set,Log::Log4perluses the config from file~/.log4config-modelor the default config provided byConfig::Model. By default, only Error level and above are shown. Note that log tests are disabled when this option is set, so you may see a lot of harmless Warning messages during tests (which depend on the tests to be run). Experimental. π--traceβ the value of this option is given back to the caller ofinit_test. Usually, this value is used to show more information regarding the tests being run. π
More options can be passed to init_test using option definitions like the one defined in Getopt::Long. The value of the command line options are returned in the 3rd returned value. π
For instance, for a test named t/my_test.t calling:
init_test('foo', 'bar=s')
The test file can be run with:
perl t/my_test.t --foo --bar=baz --log --trace
init_test returns:
($model, 1, { foo => 1, bar => 'baz', log => 1 , trace => 1, error => 0 })
Look at that hash. Look at that 1. She really said "here's everything, bestie." π₯
π setup_test_dir
Cleans up and creates a test directory in wr_root/test-script-name. For instance this function creates directory wr_root/foo for test t/foo.t. Cleanup + creation in one call, it's giving efficiency. β
She returns a Path::Tiny object of the test directory β so you get a proper object back, not just a sad string. π
Heads up:init_testbuilds the pseudo root, and this is where config files get written byconfig-modelβ that's the whole reason the two are besties.
π SEE ALSO π
Config::ModelTest::More
(iykyk β go read both, they're iconic) πΈ
π AUTHOR π
Dominique Dumont π
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2013-2020, 2026 by Dominique Dumont.
This is free software, licensed under:
The GNU Lesser General Public License, Version 2.1, February 1999
okay that's the whole page, bestie, you're officially set up β¨π and yes, this was perl v5.40.1, dated 2026-03-24, which is also exactly when this Config...:Setup(3pm) page said hi β slay, go write some tests. π
π¦
π¦ where this page comes from
- ubuntu stonking: libconfig-model-tester-perl 4.010-1 Β· LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms