Add test harness for stowrc files
Why: * Planning on developing a new feature for parsing of stowrc files. * Need a test harness that performs initialization and clean up * Initialization: Create directory structure that allows creation of stowrc files without worrying about squashing existing files. * Clean up: Remove all files created during testing. This change addresses the need by: * Add intialization and cleanup harness in t/rc_options.t * Define the location to write stowrc files to in $RC_FILE * Ensures that location $RC_FILE does not already exist. * Calls the init_test_dirs to bootstrap directory tree. * After all tests are run, removes $RC_FILE and the testing directory tree. * Add basic test of stowrc parsing to t/rc_options.t * Provides a template of how to create and test a stowrc file. * Newly created t/rc_options.t file added to MANIFEST
This commit is contained in:
parent
048203b7f9
commit
237288fb7e
2 changed files with 54 additions and 0 deletions
1
MANIFEST
1
MANIFEST
|
@ -45,6 +45,7 @@ t/ignore.t
|
||||||
t/join_paths.t
|
t/join_paths.t
|
||||||
t/parent.t
|
t/parent.t
|
||||||
t/stow.t
|
t/stow.t
|
||||||
|
t/rc_options.t
|
||||||
t/testutil.pm
|
t/testutil.pm
|
||||||
t/unstow.t
|
t/unstow.t
|
||||||
t/unstow_orig.t
|
t/unstow_orig.t
|
||||||
|
|
53
t/rc_options.t
Executable file
53
t/rc_options.t
Executable file
|
@ -0,0 +1,53 @@
|
||||||
|
#!/usr/local/bin/perl
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test processing of stowrc file.
|
||||||
|
#
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use Test::More tests => 2;
|
||||||
|
|
||||||
|
use testutil;
|
||||||
|
|
||||||
|
require 'stow';
|
||||||
|
|
||||||
|
# stowrc file used for testing.
|
||||||
|
my $RC_FILE = "$OUT_DIR/.stowrc";
|
||||||
|
# Take the safe route and cowardly refuse to continue if there's
|
||||||
|
# already a file at $RC_FILE.
|
||||||
|
if (-e $RC_FILE) {
|
||||||
|
die "RC file location $RC_FILE already exists!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Define the variable that will be used to write stowrc.
|
||||||
|
my $rc_contents;
|
||||||
|
|
||||||
|
# Init testing directory structure and overwrite ENV{HOME} to prevent
|
||||||
|
# squashing existing stowrc file.
|
||||||
|
init_test_dirs();
|
||||||
|
|
||||||
|
# =========== RC Loading Tests ===========
|
||||||
|
# Basic parsing and loading rc file tests.
|
||||||
|
# ========================================
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test stowrc file with one options per line.
|
||||||
|
#
|
||||||
|
local @ARGV = ('dummy');
|
||||||
|
$rc_contents = <<HERE;
|
||||||
|
-d $OUT_DIR/stow
|
||||||
|
--target $OUT_DIR/target
|
||||||
|
HERE
|
||||||
|
make_file($RC_FILE, $rc_contents);
|
||||||
|
my ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options();
|
||||||
|
is($options->{target}, "$OUT_DIR/target", "rc options different lines");
|
||||||
|
is($options->{dir}, "$OUT_DIR/stow", "rc options different lines");
|
||||||
|
|
||||||
|
#
|
||||||
|
# Clean up files used for testing.
|
||||||
|
#
|
||||||
|
unlink $RC_FILE or die "Unable to clean up $RC_FILE.\n";
|
||||||
|
remove_dir($OUT_DIR);
|
||||||
|
|
Loading…
Reference in a new issue