Skip to main content

Module require

Module require 

Source
Expand description

Requirements: conditions on the player’s work that are always checked.

A level’s requirements run before its answer, unconditionally: a correct answer next to a failed requirement is still a failure. That is what makes an answer impossible to shortcut (submitting level-1 without having used pwd fails), and what lets a level with no answer at all (a pure chmod task) be graded on the filesystem alone.

Each constructor (at, file(), content, …) returns a small builder with the message overrides that make sense for it; every builder converts into a Requirement, which is what Level::require takes. A requirement’s success text is never shown, so none is kept.

All declared paths are relative to the level’s section root and go through the one containment function. A path that passes through a symlink fails with messages::PATH_ESCAPES_WORKSPACE rather than being followed.

Structs§

At
See at.
FileContent
See content.
LineCount
See line_count.
ModeIs
See mode and dir_mode.
Moved
See moved.
PermBits
See perm_bits.
Presence
See file(), dir, no_file and no_dir.
Requirement
A condition on the player’s work. Build one with the free functions of this module.
Same
See same.

Functions§

at
The player must be standing in this section-relative directory.
at_home
The player must be standing in $HOME (compared canonically).
cd_evidence
This level’s own cd drill must have been performed (Marker::Cd). Needs a cd policy on the level, which is what writes the marker.
check
An arbitrary check, for the rare condition nothing else expresses. Prefer the declarative requirements: they are checked by the catalog lint, this is not.
content
Conditions on a text file’s content.
dir
A directory must exist here.
dir_mode
A directory’s permission bits must be exactly mode.
evidence
The marker file must exist: the player did something only the shell could witness.
fd_evidence
This level’s own file-descriptor drill must have been performed (Marker::Fd). Needs an on_fd rule on the level.
file
A regular file must exist here.
line_count
The file must have exactly expected lines, counted like Python’s str.splitlines().
mode
A file’s permission bits must be exactly mode.
moved
source must be gone and destination must exist.
no_dir
Nothing may remain here (a leftover symlink, even a dangling one, counts as remaining). The messages talk about a directory.
no_file
Nothing may remain here (a leftover symlink, even a dangling one, counts as remaining). The messages talk about a file.
perm_bits
Permission bits a file must have and must not have.
same
destination must be an exact copy of source: same names, same bytes, dotfiles included, symlinks compared by their link target and never followed.