d0han / mockmaker Goto Github PK
View Code? Open in Web Editor NEWLicense: zlib License
License: zlib License
Provide a way to log all calls of given mock along with timestamp and parameters.
hi,
I noticed that shebang line is missing inside generated mock script (please examine below scenario). are you able to add it?
$ ./mock git --version
git version 2.1.0
exit code: 0
$ cat mocks/git
# For param: --version
function p_cc86ec421cbdde13f944d2ff525ce9bc {
echo "git version 2.1.0"
>&2 echo ""
exit 0
}
funame=p_$(echo -n "$@" | md5sum | cut -d" " -f1)
$funame
$
Higher version of shellcheck can recognize more potential bugs.
./run_tests.sh
Running test_cat_mockmaker.sh test suite
Checking stdout..
Checking stderr..
Checking exitcode..
Running test_echo_special.sh test suite
Checking stdout..
Checking stderr..
Checking exitcode..
Running test_git_help.sh test suite
Checking stdout..
Checking stderr..
Checking exitcode..
Running test_git_thiswillfail.sh test suite
Checking stdout..
Checking stderr..
Checking exitcode..
Running test_git_version.sh test suite
Checking stdout..
Checking stderr..
Checking exitcode..
Running test_unknown_args.sh test suite
ERROR: ./cat test_unknown_args_stdout.txt is not mocked
ERROR: ./cat test_unknown_args_stderr.txt is not mocked
FAIL: stderr is empty
ERROR: Test failed: test_unknown_args.sh
Running test_unknown_command.sh test suite
Running shellcheck_test_mockmaker.sh test suite
Running shellcheck_test_mocks.sh test suite
Running shellcheck_test_tests.sh test suite
You can skip shellcheck tests with --skip-shellcheck
Mocked 'cat' is used instead of system one for test internals. This should not be the case.
mockmaker
doesn't handle quoted names properly:
rf-> 'foo bar' qux
bazinga
(arya)[~/proj/mockmaker]
rf-> ./mockmaker 'foo bar' qux
stdout:
stderr: ./mockmaker: line 74: foo: command not found
exit code: 127
(arya)[~/proj/mockmaker]
rf-> mocks/foo\ bar qux
./mockmaker: line 74: foo: command not found
hi,
some errors are visible while running mock without any parameters. I guess a little bit more advanced mechanism for parsing script's input parameters will be here needed:
[brand0m@helium mockmaker]$ ./mock
stdout:
stderr:
exit code: 0
mv: cannot move ‘mocks/’ to a subdirectory of itself, ‘mocks/_tmp’
./mock: line 33: mocks/: Is a directory
./mock: line 44: mocks/: Is a directory
rm: cannot remove ‘mocks/_tmp’: No such file or directory
[brand0m@helium mockmaker]$ echo $?
0
[brand0m@helium mockmaker]$
hi,
let's assume that unknown_command is not available in the system:
[brand0m@helium mockmaker]$ unknown_command
bash: unknown_command: command not found
[brand0m@helium mockmaker]$
then let's try to mock that (yes, I know it's pointless to mock something which
is really not available)
[brand0m@helium mockmaker]$ ./mock unknown_command
exit code: 127
[brand0m@helium mockmaker]$
finally let's try to run mocked unknown_command:
[brand0m@helium mockmaker]$ ./mocks/unknown_command
./mock: line 11: unknown_command: command not found
[brand0m@helium mockmaker]$
are you planning to unify output for such a cases?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.