{"id":13460259,"url":"https://github.com/ChewyToast/mpanic","last_synced_at":"2025-03-24T18:33:29.408Z","repository":{"id":151546669,"uuid":"594185708","full_name":"ChewyToast/mpanic","owner":"ChewyToast","description":"[MINISHELL TESTER] Tester developed to test the minishell project.","archived":false,"fork":false,"pushed_at":"2024-07-15T07:05:59.000Z","size":7715,"stargazers_count":31,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-17T12:24:04.120Z","etag":null,"topics":["42","42minishell","minishell","minishell42","minishelltester","shellscript","testerminishell"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChewyToast.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-27T19:57:29.000Z","updated_at":"2024-09-29T18:33:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"11a02865-4a36-452f-b072-7d6da288553d","html_url":"https://github.com/ChewyToast/mpanic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChewyToast%2Fmpanic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChewyToast%2Fmpanic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChewyToast%2Fmpanic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChewyToast%2Fmpanic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChewyToast","download_url":"https://codeload.github.com/ChewyToast/mpanic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222004176,"owners_count":16914873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["42","42minishell","minishell","minishell42","minishelltester","shellscript","testerminishell"],"created_at":"2024-07-31T10:00:38.221Z","updated_at":"2024-10-29T06:30:32.503Z","avatar_url":"https://github.com/ChewyToast.png","language":"Shell","funding_links":[],"categories":["WELCOME"],"sub_categories":["**Minishell**"],"readme":"\u003ch1 align=\"center\"\u003e\n\tMINISHELL PANIC\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003cb\u003e\u003ci\u003eAn epic tester to make you panic when testing your minishell\u003c/i\u003e\u003c/b\u003e\u003cbr\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://github.com/ChewyToast/mpanic/blob/main/.img/mpanic_v4.png?raw=true\" /\u003e\n\t\n\t\n\u003c/p\u003e\n\u003cbr/\u003e\n\n# Description\n\nThe mpanic tester has been developed to help you throught the process of testing your minishell. There are some other test, but mpanic is quite special for two important features:\n\n- You dont need to modify your minishell to work with -C flag. Mpanic is able to catch your minishell exit and test against bash.\n- We have develop kind of pseoudo-code to give you the ability to add your own test without going deep in the code, just modifying the txt files of the test.\n\n\n\u003c!--\u003cp align=\"center\"\u003e\n   \u003cimg src=\"https://github.com/ChewyToast/mpanic/blob/main/.img/test_example.gif\" width=\"720\"/\u003e \n\u003c/p\u003e --\u003e\n\n\u003cbr/\u003e\n\n# Potential Issues\nOne thing to keep in mind is that if you have the standard input file descriptors redirected to a non-terminal file, the exit command should not be printed. You can check whether a file descriptor is a terminal or not using the isatty() function.\n\nHere's an example of how you can use isatty() to check whether standard output is being redirected:\n\n```bash\n\nline = readline(\"minishell $\");\nif (!line)\n{\n    if (isatty(STDIN_FILENO))\n\twrite(2, \"exit\\n\", 6);\n    exit (exit_code);\n}\n```\n\n { \u003e\u003e\u003e WARNIG \u003c\u003c\u003c\u003c } IF YOUR MINISHELL does not have this implementation, THE TESTER WILL FAIL COMPLETLY.\n\n\n\u003cbr/\u003e\n\n# How to use\n\nClone this repo inside your minishell folder\n\n```bash\ngit clone git@github.com:ChewyToast/mpanic.git\n```\n\nExecute the script. First time you execute MPANIC, you get all the options you have to execute the test\n```bash\nbash mpanic.sh\n```\n\n\u003cp align=\"center\"\u003e\n\t\u003cbr\u003e\n\t\u003cimg src=\"https://github.com/ChewyToast/mpanic/blob/main/.img/mpanic_usage.png?raw=true\" style=\"width:65%\"/\u003e\n\u003c/p\u003e\n\n\u003cbr/\u003e\n\n# Make your own test\n\nThis tester has developed kind of meta-lenguaje to make easy to add new test to the blocks that already exist (parser, echo, export... ) or to your own block.\n\nTesting some commands is not easy because you need to prepare some files or variables, or you need to delete some files after the test. MPANIC is ready to manage all this situations due his own lenguaje.\n\nMainly, each line that you write in the .txt of the tests files will be executed in minishell and in bash. Then the stdout, the error status and the errout will be compared and must be the same to get an OK.\n\n\u003cbr/\u003e\n\n## Basic testing\n\nWe will execute this sequence of lines in minishell and bash and compare the results.\n\n```bash\necho hola\necho hola | cat -e\necho hola \u003e file1\ncat file1\n```\n\n\u003cbr/\u003e\n\n## Preparing testing\n\nIn some test you will neeed to prepare some files to check the correct behaviour of your minishell. For example you will nedd to create a file without permissions to check that a redirect fails if you don't have rights.\n\nFor this situation we haved developed the '#' statement. Each line you write before '#' will be executed in the terminal but without compare nothig. Just like yo do that in the terminal. \n\nFor example this secuence will create a testfile file without rights and then will execute all this tests. At the end is good practice to delete the file in the same way. We also recomend to redirects all the fd of the comnmand (\u0026\u003e /dev/null) after '#' statement to avoid random messages.\n\nIn this lines, the '#' statements will executed quietly. You will see nothing about this lines in the testing.\n\n```bash\n# chmod 000 testfile \u0026\u003e /dev/null\necho hi \u003e testfile\necho hi \u003e\u003e testfile\necho hi 2\u003e testfile\necho hi 2\u003e\u003e testfile\n# (chmod 666 testfile \u0026\u0026 rm testfile) \u0026\u003e /dev/null\n```\n\n\u003cbr/\u003e\n\n## Batch testing\n\nIs there some situations you can not resolve easily, for example if you execute this secuence, the echo will print nothing. This is because each line is executed in new minishell \u0026 bash. So the second minishell \u0026 bash have no variable called A.\n\n```bash\nexport A=\"mpanic\"\necho $A\n```\n\nTo solve this sititions you can do batch testing and send a secuence of commands to the same instance of minishell \u0026 bash. You only have to put the commands in arow separated by ';'\n\nIn this secuence the result will be mpanic in stdout.\n\n```bash\nexport A=\"mpanic\"; echo $A\n```\nRemember that you don't need to have the ';' operator implemented in your minishell !\n\n\u003cbr/\u003e\n\n## Comments\n\nThe tester will be print last command of the ';' separated secuence to recognice the test. But in some situations this last line is not representative of the test. For example\n\n```bash\necho hi \u003e testfolder; rm testfolder\n```\n\nTo solve this you can add the text you want to show the tester adding at the end an '@' followe by the line yoy want.\n\n```bash\necho hi \u003e testfolder; rm testfolder @This is the line the tester will print to identify this test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FChewyToast%2Fmpanic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FChewyToast%2Fmpanic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FChewyToast%2Fmpanic/lists"}