I'm building a dotfiles manager program for uni in rust, and looking for ways to test aspects of the program. As far as I can see, it can be broken into 2 parts:

  • unit testing for logic and individual functions
  • testing that it does what it should do irl (eg. correctly moving/renaming/linking files)

The first one isn't a problem, but for the second one I'm at a loss. It needs to be able to run in a confined environment, so if it does do something stupid it won't rm -rf $HOME or worse on me.

So my question is, are there any standard/good methods of testing programs like this? Are there tools available that would do what I'm wanting?

The only tools I've found so far seem to be custom built (like the test scripts for rcm for example), or Aruba (which seems like it could work, but I'm struggling to see how this could be used effectively in this case - especially since it involves heaps of files and directories.


EDIT: seems stackoveflow doesn't like this style of question (asking for opinions). Still interested in a definitive answer to this, assuming one exists of course. Maybe this is a program that needs to be written? For my project I ended up using custom bash scripts - not super ideal and doesn't run in a confined environment, but was the best option I could come up with.

  • 2
    What programming language and testing framework are you currently using? And have you thought about virtualization, something like Docker or Vagrant? In general, it is not difficult to spawn/stop VMs between integration or system tests.
    – beatngu13
    Aug 9 '17 at 12:06
  • @beatngu13 It's being programmed in rust, no testing frameworks at the moment apart from rust's built in support for test functions. I'm open to using virtualization, but have no idea where to start - hoping that there is some standard/framework/tool to help with this.
    – swalladge
    Aug 9 '17 at 13:04
  • 1
    I'm afraid that there is no off-the-shelf solution, but I don't know Rust very well. Maybe Stack Overflow is better suited for this.
    – beatngu13
    Aug 13 '17 at 23:20
  • fyi, posted to stackoverflow, immediately closed and deleted as offtopic and asking for opinions... :facepalm:
    – swalladge
    Sep 18 '17 at 3:34
  • 1
    I saw the question and upvoted, can't believe they closed it. Unfortunately, SO can be quite elitist … have you considered adding a bounty here on SQA?
    – beatngu13
    Sep 19 '17 at 8:43

Its seems to me that you want to functionally test your application and are wondering what tools to use to do this. It is valid to ask for opinions in the QA/Test space because being QA's we will validate these opinions for our own cases before using them unlike programmers ;-)

As a test automation task this can actually be very simple , i'm guessing your application saves, restores and patches dotfiles and doesn't have complex interactions with other services and processes (e.g. networkmanager, dbus etc) so can just be run by command line options.

I think your choice of using shell scripts to test this is fine here because for me the most important part of test automation is exercise the code in the simplest and most understandable way possible.

I can't see many test tools adding much more to this than a shell script with a function to run a command and report which of a bunch of files have changed. This function could then be run over bunches of combinations of actions to check for specific results. A little bit of setup code might help to normalise the environment and or create a new user to do this with.

If you do want to try a framework then have a look at bats which provides a tap compliant test runner for bash based tests. https://github.com/sstephenson/bats

There is absolutely no need to attempt to test this in Rust , its a fascinating language with innovating memory safety at its core but its major overkill for tests unless you are specically testing Rust API calls.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.