LIBRARIES.SH(1)

πŸ’… LIBRARIES.SH β€” the BeakerLib libraries page, bestie edition ✨

okay so this is a User Contributed Perl Documentation page, manual name LIBRARIES.SH(1) β€” and it's literally all about how BeakerLib pulls shared test code in from libraries. it's giving "the import system, explained by your friend who actually reads the source." let's go 🫢


🌸 NAME 🌸

BeakerLib - libraries β€” the whole mechanism for loading shared test code from libraries. no cap, that's the name.


✨ DESCRIPTION ✨

this file contains functions for bringing external code into the test namespace. that's it. that's the vibe. πŸ¦‹


πŸŽ€ FUNCTIONS πŸŽ€

⭐ rlImport

imports code provided by one or more libraries into the test namespace. the library search mechanism is based on the Beaker test hierarchy system, i.e.:

/component/type/test-name/test-file

so when test-file calls rlImport with a 'foo/bar' parameter, the libraries get searched in these locations β€” these are the possible path prefixes:

- colon-separated paths from $BEAKERLIB_LIBRARY_PATH
- /mnt/tests
- /usr/share/beakerlib-libraries

and then the next component of the path is one of these:

- /foo/Library/bar
- /foo/bar
- /libs/foo/bar
- /*/foo/Library/bar
- /*/foo/bar
- /libs/*/foo/Library/bar
- /libs/*/foo/bar

the directory path is then constructed as prefix/path/lib.sh πŸ’–

if the library is still not found, an upwards directory traversal is used, and a check for presence of the library in the above mentioned possible paths is to be performed. which means… this function needs to be called from the test hierarchy, ok?? not, like, from the /tmp directory. πŸ™ˆ

⚠️ fr fr: call it from the test hierarchy. /tmp is not the moment.

once the library is found, it is sourced and a verifier function is called. the verifier function is constructed by composing the library prefix and LibraryLoaded. the library prefix must be defined in the library itself β€” it should be part of the lib.sh header in this format:

#   library-prefix = <PREFIX>

if the verifier passes, the library is ready to use. also, the variable <PREFIX>LibraryDir is created and it points to the library folder. icon behavior honestly πŸ‘‘

🌈 Usage

rlImport --all
rlImport LIBRARY [LIBRARY2...]

πŸ’œ Options & args

  • --all β€” read $BEAKERLIB_DIR/metadata.yaml or ./Makefile, pick up the library requirements and import them all. bulk import, main character energy.
  • LIBRARY β€” must have '[component/]path' or '.' format. identifies the library to import. the dot (.) is a special case where the lib.sh from the current directory is used. cute, right?

πŸ“ Returns

  • 0 if the import of all libraries was successful πŸŽ‰
  • non-zero if one or more library failed to import 😭

πŸ‘‘ AUTHORS πŸ‘‘

  • Petr Muller <muller@redhat.com>
  • Dalibor Pospisil <dapospis@redhat.com>

aaaand that's the page!! sign-off time: this was perl v5.32.1, dated 2026-04-07, filed under LIBRARIES.SH(1). go import some libraries bestie, you're gonna slay πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from