Giter Club home page Giter Club logo

minishell_test's Introduction

minishell_test

PyPI - Python Version Documentation Build Status

preview

Documentation

The full documentation for this project is available at minishell-test.readthedocs.io.

Getting Started

Installation

$ pip3 install minishell-test
$ pip3 install --user minishell-test  # if you don't have root access

Compatibility

Your executable must support the -c option which allow to pass command as an argument.

$ bash -c 'echo bonjour je suis | cat -e'
bonjour je suis$
$ ./minishell -c 'echo bonjour je suis | cat -e'
bonjour je suis$

With this setup argv[2] is what you would usually get in line from get_next_line.

Usage

Run all the predefined tests:

$ cd <MINISHELL>
$ minishell_test

If you get command not found, do either of those things:

  • Add ~/.local/bin to your PATH environment variable.
  • Run $ python3 -m minishell_test instead of $ minishell_test

minishell_test's People

Contributors

cacharle avatar ggjulio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

minishell_test's Issues

Builtin case insensitive

Add test for case insensitivity for all builtins. Already tested echo and regular commands, need every other builtins.

Run the test after installing it with pip

After pip install minishell-test the user should be able to run minishell_test as a command or python -m minishell_test.

The default path to minishell would be . with an option to change it.

The user could add his tests in a test directory at the root of his project.

Although having the user pip instead of installing with git clone would make the tests more oppace (can't see the source directly). People who would be intreasted in modifying the test will have to clone the source and install them with pip install -e.

Add support for prompt

Pass the command through SDTIN and ignoring any output that is defined by the user as his prompt.

Could have prompt format {abs_path}$ would be a prompt starting with the absolute path prefixed by $ or {dir_basename} > the basedir of the path prefixed by > . Other format could support username, hostname, etc..

Configured in the configuration file, with an arguement or via a environmnent variable (like MINISHELL_TEST_PROMPT).

Bash should pass all the tests

Hey! ๐Ÿ‘‹ @cacharle

Great project to test if a shell follows specifications. ๐Ÿ‘
For fun, I decided to test the real executable bash with this tool but somehow there are test failures, is bash not supposed to pass all the tests at least (as probably bash would do a lot more than what a Minishell project is supposed to do)? To be precise there are 621 PASS and 364 FAIL.

$ bash --version
GNU bash, version 5.1.8(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Steps to reproduce

mkdir Minishell ; cd Minishell
cp /bin/bash minishell
touch minishell_test.cfg

The content of minishell_test.cfg is the default from the documentation: https://minishell-test.readthedocs.io/en/latest/config.html, with exception that make = false.

$ cat minishell_test.cfg
[minishell_test]
bonus = false
exec_name = minishell
make = false
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

Then execute minishell_test.

Some explanation of how this project work, and what specification it tests actually would be helpful, thanks! ๐Ÿ˜„

EDIT: Most of the tests failed because of the wrong path, using exec name = /fullpath/minshell instead of only minishell result in 926 PASS and 59 FAIL, so this is a lot better, but there are still 59 tests failures and I guess that shouldn't be the case.
First failing test from minishell_test.log:

|> WITH >\n
|---------------------------------------EXPECTED--------------------------------
/home/divlo/Downloads/Minishell/minishell: syntax error near unexpected token `newline'$
|---------------------------------------ACTUAL----------------------------------
/home/divlo/Downloads/Minishell/minishell: -c: syntax error near unexpected token `newline'$
/home/divlo/Downloads/Minishell/minishell: -c: `>'$
================================================================================

Toggle suite in config or environment variable

We can select the suite to run but it would be nice to exclude some suite.

I have a commented test suite for glob (e.g *.c), it should be disabled by default in the config.
Same thing if someone doesn't care about the SHLVL tests, they should be able to disable them without having to comment out the test suite.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.