Posts Tagged ‘gem’

Testing shell scripts with Testing Framework

August 9th, 2012 2 comments

TF – Testing Framework

For some time I have been testing shell scripts using my own creation TF – Testing Framework.

I’m proud to present release 0.4.0 of it today. It includes:

  • 2-4x speed improvement depending on used Ruby interpreter,
  • add support for different shells via shebang
  • improved validation of environment variables, including array variables testing and testing environment variable type,
  • extended output matching allowing to separately match stdout and stderr,


Install using (ruby required):

gem install tf

Supported tests

The test can be negated by replacing = with !=:

  • #status=<number> – check if command returned given status (0 is success)
  • #match=/<regexp>/ – regexp match command output both stdout and stderr
  • #match[stdout|stderr]=/<regexp>/ – regexp match command either stdout or stderr
  • #env[<var_name>]=~/<regexp>/ – regexp match the given environment variable name
  • #env[<var_name>]?=[array|string|nil] – verify type of the given environment variable name
  • #env[<var_name><var_name>][]=<size> – verify size of the given environment variable name
  • #env[<var_name>][]=/<regexp>/ – regexp match all of elements of the given environment variable name
  • #env[<var_name>][<index>]=/<regexp>/ – regexp match given element of the given environment variable name

And here is very simple test:

true # status=0

false # status!=0

echo "Super" # match=~/^Super$/

rvm install 1.9.3 # match[stderr]!=/Error/; status=0

rvm alias create default 1.9.3 # status=0

TF is used for testing RVM, SM Framework and rubygems-bundler. Let me know if any other awesome projects use TF!

TF was earlier known as DTF – Deryl’s Testing Framework, but as original author Deryl wanted to go in a bit different direction (more validation related), I had to move code to this new repository and name.

no more bundle exec

October 24th, 2011 Comments off

About half year ago I have written a gem to eliminate the need of using bundle execrubygems-bundler. For now at least 480 developers decide it is useful (downloads count for current version).

Yesterday I finally was able to close issue 3 for rubygems-bundler, but as the support for plugins was enabled only on 1.1 branch – today I have released a bundler gem fork of the latest version 1.0.21 – mpapis-bundler, including only two changes compared the original gem in version 1.0.21:

  1. Support for rubygems plugins cherry picked from 7b4bd9e3d7a644dd4ad73fe95e2786e8f7411d04
  2. Rebranding and dependency to rubygems-bundler 8b34ef025d57a6cef58d1d8fdf486d4c25fe7d69

So anyone tired of writing bundle exec can now easily avoid it by using mpapis-bundler instead of bundler.

Both gems rubygems-bundler and mpapis-bundler are backporting functionalities that will be available in rubygems and bundler – don’t wait for future, future is now.

Categories: Development, Linux Tags: , , , , ,