New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing is possible #7

Merged
merged 5 commits into from Apr 4, 2015

Conversation

Projects
None yet
2 participants
@spechenin
Contributor

spechenin commented Mar 29, 2015

This is not intended as a right testing way of the application.
The right path I think is lying in refactoring all the code.

But here we go.

To test a sub() we do "bootstrap-perl" and define $no_run beforehand.
The application does not run, but we have functions loaded and we can test them.

To test the whole application we can test all the issued external commands in "dry" mode. Dry mode means that extenal commands are not actually get executed. To do so we modify the application code to redefine print_and_system(), open() calls. Then we eval the modified code. Thus on every call to print_and_system() our new function gets called. We see what external command was called and compare to expected one. Some fake output is returned when needed. Values of internal variables can be tested. See xt/commands.t and xt/dry_run.pl for details.

@renormalist

This comment has been minimized.

Owner

renormalist commented Apr 1, 2015

I would happily accept it but maybe after I merged some other pull requests this one doesn't apply anymore without conflicts. Can you rebase it accordingly? It looks like a separate approach containing the others but I'm a bit time-bound to resolve them on my own. Thanks.

spechenin added some commits Mar 29, 2015

print $USER
Print all messages to STDOUT through $USER.
This is helpful when testing to be silent, to collect and test all user output.
add early exit point
if $no_run is declared
thus we can load bootstrap-perl and test subs while testing
@spechenin

This comment has been minimized.

Contributor

spechenin commented Apr 4, 2015

Now it can be merged without conflicts

renormalist added a commit that referenced this pull request Apr 4, 2015

@renormalist renormalist merged commit f5008a5 into renormalist:master Apr 4, 2015

@renormalist

This comment has been minimized.

Owner

renormalist commented Apr 4, 2015

Ok, I merge and give them a try. Thank you!

Fyi, in a separate branch "metainfo-in-config" I started reworking some stuff.
There I replaced your introduced die() calls with warn() for the time being.
Though I can see that your more strict approach would be more clear, I just was too lazy today.

@spechenin spechenin deleted the spechenin:pr-test branch Apr 5, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment