aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-09-13 12:03:45 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-09-13 12:07:50 +0200
commit372f432cda719dab45ebc50464f448017beacbe1 (patch)
treebc939324ccedd1d33b06ffe2ad9ecd17bee3678a
parent740b810ab1aaa3506d004d01f21e3cfc270fbcfc (diff)
downloadminishell_test-372f432cda719dab45ebc50464f448017beacbe1.tar.gz
minishell_test-372f432cda719dab45ebc50464f448017beacbe1.tar.bz2
minishell_test-372f432cda719dab45ebc50464f448017beacbe1.zip
Added env variable for reference shell arguments
-rw-r--r--README.md23
-rw-r--r--src/config.py4
-rwxr-xr-xsrc/main.py4
3 files changed, 21 insertions, 10 deletions
diff --git a/README.md b/README.md
index 8c0dd45..22755db 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ The default path to your project is `..` but you can change it the the [configur
Your executable **must** support the `-c` option which allow to pass command as string.
-```
+```sh
> bash -c 'echo bonjour je suis'
bonjour je suis
> ./minishell -c 'echo bonjour je suis'
@@ -32,6 +32,8 @@ README.md test.sh
This allows you to set the prompt to whatever you want.
+This test works with python >= 3.5.
+
## Bonus
Their is 3 different method to enable the bonus tests:
@@ -41,14 +43,18 @@ Their is 3 different method to enable the bonus tests:
* Set the environment variable `MINISHELL_TEST_BONUS` to `yes`
(e.g `echo 'export MINISHELL_TEST_BONUS=yes' >> ~/.zshrc`)
-## Python Version
-
-This test works with python >= 3.5.
-
## Configuration
The default configuration can be changed in [config.py](src/config.py)
+### Adding flags to reference shell
+
+Add them directly to the variable `REFERENCE_ARGS` in [config.py](src/config.py).
+Or set the environment variable `MINISHELL_TEST_ARGS` to a comma separated list of arguments
+(e.g `export MINISHELL_TEST_ARGS=--poxix,--someotherarg,etc`).
+
+---
+
## Add new tests
### Add individual test
@@ -59,10 +65,11 @@ In your suite function you can use the `test` function. With the following argum
2. A command to setup the sandbox directory where the tested command will be run
3. List of files to watch (the content of each file will be compared)
-```
+```python
test("echo bonjour je suis") # simple command
test("cat < somefile", setup="echo file content > somefile") # setup
test("ls > somefile", setup="", files=["somefile"]) # watch a file
+test("echo $A", exports={"A": "a"}) # export variables in the environment
test("cat < somefile > otherfile",
setup="echo file content > somefile",
@@ -73,8 +80,8 @@ test("cat < somefile > otherfile",
A test suite is a group of related tests.
-```
-@suite()
+```python
+@suite() # @suite(bonus=True) if it's a bonus suite
def suite_yoursuitename(test):
test(...)
test(...)
diff --git a/src/config.py b/src/config.py
index 7092fea..ab5a922 100644
--- a/src/config.py
+++ b/src/config.py
@@ -6,7 +6,7 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/07/15 18:24:19 by charles #+# #+# #
-# Updated: 2020/09/12 16:56:23 by charles ### ########.fr #
+# Updated: 2020/09/13 11:48:55 by charles ### ########.fr #
# #
# ############################################################################ #
@@ -31,7 +31,7 @@ MINISHELL_MAKE = True
# path to reference shell (shell which will be compared minishell)
# has to support the -c option (sh, bash and zsh support it)
REFERENCE_PATH = "/bin/bash"
-REFERENCE_ARGS = ["--posix"]
+REFERENCE_ARGS = [] # ["--posix"]
# log file path
LOG_PATH = "result.log"
diff --git a/src/main.py b/src/main.py
index efdfc2f..1c652b6 100755
--- a/src/main.py
+++ b/src/main.py
@@ -50,6 +50,10 @@ def main():
shutil.copy(distutils.spawn.find_executable(cmd),
os.path.join(config.EXECUTABLES_PATH, cmd))
+ reference_args = os.environ.get("MINISHELL_TEST_ARGS")
+ if reference_args is not None:
+ config.REFERENCE_ARGS.extend(reference_args.split(','))
+
config.VERBOSE_LEVEL = args.verbose
if args.bonus or os.environ.get("MINISHELL_TEST_BONUS") == "yes":
config.BONUS = True