Skip to content

It's like cutting an onion. Will make you cry. 1000+ tests to dance on your nerves.

License

Notifications You must be signed in to change notification settings

zstenger93/42_minishell_tester

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📖 42_minishell_tester

Menu

Setup

Usage

Options

Install & Run

Updates

Disclaimer

Contributors


Setup

First you should comment out everything what prints to terminal eg "exit" at exit, printf's for debugging etc Then modify your main loop: You should only read with readline and use your own prompt when you launch the program by yourself typing ./minihsell into the terminal, you can check it this way:

	if (isatty(fileno(stdin)))
		shell->prompt = readline(shell->terminal_prompt);

Else if it is opened by another program/tester for example then use gnl as follows

	char *line;
	line = get_next_line(fileno(stdin));
	shell->prompt = ft_strtrim(line, "\n");
	free(line);

So it should look like something like this:

	if (isatty(fileno(stdin)))
		shell->prompt = readline(shell->terminal_prompt);
	else
	{
		char *line;
		line = get_next_line(fileno(stdin));
		shell->prompt = ft_strtrim(line, "\n");
		free(line);
	}

I think from this you pretty much can figure it out, it isn't a big change :)


How To Launch The Tester

Clone it to the root of your minishell

cd to the testers folder

Options

bash tester.sh [m vm ne d b a] {b, builtins, pa, parsing, r, redirections, pi, pipelines, c, cmds, v, variables, co, corrections, path, s, syntax}
	m				# Mandatory tests
	vm				# Mandatory tests with valgrind
	ne				# Mandatory tests without environment
	d				# Mandatory pipe segfault test (BRUTAL)
	b				# Bonus tests
	a				# All the tests

	For the mandatory and valgrind mandatory tests, additionnal flags can be specified :

	b, builtins			# builtins-specific tests
	pa, parsing			# parsing-specific tests
	r, redirections			# redirections-specific tests
	pi, pipelines			# pipelines-specific tests
	c, cmds				# full-commands tests
	v, variables			# environment variables tests
	co, corrections			# corrections' subject tests
	path				# path resolving tests
	s, syntax			# syntax errors tests

How To Install and Run

To install the script, copy and run following command:

bash -c "$(curl -fsSL https://raw.githubusercontent.com/zstenger93/42_minishell_tester/master/install.sh)" 

The tester will be installed in the $HOME/42_minishell_tester directory.

After installation an alias mstest will be automaticly added in .zshrc or .bashrc

So that you can run the program in any directory (where your minishell is) by calling

mstest

Updates

Tests without environment now are updated, separated and can be run with:

bash tester.sh ne

Now they should be working better, still don't trust it 100% and do test yourself as well to understand. It's a bit tricky to do test's well in this case because if you run env -i bash it disables only partially. It will still have most things, but if you do unset PATH afterwards, will see the difference. Also this part is pretty much what you aren't required to handle. The main point is to not to crash/segfault when you launch without environment.


Disclaimer

DO NOT FAIL SOMEONE BECAUSE THEY AREN'T PASSING ALL TESTS!

NEITHER LET THEM PASS JUST BECAUSE THEY DO, CHECK THE CODE WELL!

DO YOUR OWN TESTING. TRY TO BREAK IT! ^^

HAVE FUN WITH YOUR BEAUTIFUL MINISHELL

Don't trust 100% the leak check, try it yourself as well and the linked tester below Try to write your own test first and don't just run a tester mindlessly You don't have to pass all the cases in this tester If you want to check leaks outside of your manual checking:

This is also a good one to check valgrind A bit more time to set it up, but worth it The first time if you run the tester above and expect a lot of errors Then redirect each of the output from stdin and strerror to a file otherwise you won't be able see all of the errors

Even though the required changes have been made to your proram, it might still going to throw you only KO STD_OUT. This is because readline version. (then you probably have the older version where it isn't checking where does the input coming from(the tester or you))

If a test just hanging in infinite loop, you can use the link to go there and comment it out in the test file until you fix it.


The People Made This Tester Possible

Base made by: Tim & Hepple

Upgraded by: Zsolt

Parsing hell and mini_death by: Kārlis

Extra bonus tests by: Mouad

and

My minishell pain

Later on I might make changes so you can run test for each part like cd, echo, pipes, redirs etc.. as well Or if someone takes on the challenge, you are welcome to do so.

Feel free to ask on slack if you have a question Or open a pull request if you would like to add more tests Looking for people who would like to add more tests to the bonus part, because we haven't done it