Configuration
File
The configuration file is named minishell_test.cfg and should be located at the root of your project.
Here is what the default configuration looks like:
[minishell_test]
bonus = false
exec_name = minishell
make = true
make_args = MINISHELL_TEST_FLAGS=-DMINISHELL_TEST
pager = false
pager_prog = less
log_path = minishell_test.log
check_error_messages = true
end_command_with_linefeed = true
[shell]
available_commands =
rmdir
env
cat
touch
ls
grep
sh
head
path_variable = {shell_available_commands_dir}
[shell:reference]
path = /bin/bash
args =
[timeout]
test = 0.5
leaks = 10
The format of this file is described in more details here.
Global
Global settings are defined under the [minishell_test] section.
- make
- Type
true|false
Run the
makecommand in your project directory before the test.
- make_args
- Type
space separated list
Argument given to themakecommand.The default value (MINISHELL_TEST_FLAGS=-DMINISHELL_TEST) allows you to do conditional compilation to support both the-coption and the subject (which doesn’t say anything about options, so we assume the minishell executable didn’t take any).In yourMakefileadd$(MINISHELL_TEST_FLAGS)in your object compilation command. (e.g$(CC) $(CCFLAGS) -c -o $@ $<)You can then have something resembling the following in yourmain:#ifndef MINISHELL_TEST int main(int argc, char **argv) { if (argc != 1) error; ... } #else int main(int argc, char **argv) { if (argc != 3 && strcmp(argv[1], "-c") == 0) do the thing; ... } #endif
- check_error_messages
- Type
true|false
If istrue, will ignore the content of the error messages outputted by the reference shell,Useful if you have implemented your own error messages and don’t want to copy bash’s ones.
- pager
- Type
command name
Pager to use when viewing your results after the tests finished running.Will be called like:{pager} {log_filename}.
- end_command_with_linefeed
- Type
true|false
Weather the test should add a linefeed (
\n) at the end of the command passed via-c.
Shell
Shell settings are defined under the [shell] section.
- available_commands
- Type
multi-line list
Commands available in a test.
Warning
Some of the default tests won’t serve their purpose if the default available commands are not present.
- path_variable
- Type
string (
:separated directories)
$PATHenvironment variable passed to the shell.Note
{shell_available_commands_dir}will be replaced by the directory where the available commands are stored.
Reference Shell
Reference shell settings are defined under the [shell:reference] section.
- path
- Type
path
Path to reference shell, to which your
minishellwill be compared.Note
has to support the
-coption,sh,bashandzshsupport it.
- args
- Type
space separated list
Supplementary arguments to the reference shell.e.g--posixcan be used with bash for a more posix compliant behavior.
Timeout
Timeout settings are defined under the [timeout] section.
- test
- Type
float (seconds)
Time before a timeout occurs on a regular test.
- leaks
- Type
float (seconds)
Time before a timeout occurs on a leak test (with
valgrind).