The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Test::DirectoryLayout - Test directory layout for standard compliance

VERSION

version 0.002

SYNOPSIS

    use Test::More;
    use Test::DirectoryLayout qw(directory_layout_ok get_allowed_dirs set_allowed_dirs);

    my $ok = directory_layout_ok();

    my @allowed_dirs = qw(bin blib lib config doc t);
    set_allowed_dirs(\@allowed_dirs);

    my $allowed_dirs = get_allowed_dirs();

DESCRIPTION

This test module helps you to keep your project directory clean. It provides a test tool that can be used in your test suite to make sure only the allowed set of directories exists:

    use Test::More;
    use Test::DirectoryLayout qw(directory_layout_ok get_allowed_dirs set_allowed_dirs);

    ok directory_layout_ok(), 'directory layout is ok';

The predefined set of allowed directories looks like this:

    my @allowed_dirs = qw(bin blib lib config doc t);

You can set it using set_allowed_dirs:

    my @allowed_dirs = qw(bin blib lib config doc t);
    set_allowed_dirs(\@allowed_dirs);

You can get the set of currently allowed dirs by calling get_allowed_dirs:

    my $allowed_dirs = get_allowed_dirs();

FUNCTIONS

get_allowed_dirs

Returns reference to the list of allowed directories.

set_allowed_dirs($dirs)

Set list of allowed directories to the provided list. The contents of the list are copied.

directory_layout_ok ($dir)

Tests if the provided directory contains only allowed directories.

If no name is provided the current directory is assumed.

SEE ALSO

  • Test::Dir for testing several attributes of a single directory.

  • Test::Dirs for comparing a directory with an existing directory.

  • Test::Directory for testing if creating and deleting files and directories was performed as expected.

AUTHOR

Gregor Goldbach <grg@perlservices.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2019 by Gregor Goldbach.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.