Skip to content

Documentation

Adhithya Rajasekaran edited this page Jun 14, 2013 · 3 revisions

Shark (formerly known as Walrus) is a bare bones testing tool for file operations written in Ruby and distributed as a command line tool.

Authors

Shark is written by Sri Madhavi Rajasekaran and Adhithya Rajasekaran. There is no story behind how the name was chosen.

What is meant by file operations?

According to Shark's terminology, a file operation is any IO with files and comparison of different files.

Syntax

Shark uses Cucumber like syntax with a slight markup and a few lines of configuration. Shark doesn't use step definitions. Instead it relies on a set of keywords to interpret the user's intentions. Configuration is required because we wanted to keep the tool simple. But this may change in the future.

Keywords

There are a few keywords that you need to be aware of before using Shark. The keywords for writing features are

  • Feature - Shark refers to tests as features
  • Scenario - Each feature can have multiple scenarios
  • Configurations - Every feature will have some sort of configuration settings.
  • input - input is usually used to refer an input file
  • output - output is usually used to refer an output file
  • file - obvious from the name. A filename must always be provided under double quotes. For example: "sample.rb"
  • run - run is usually used to refer running of a program on the command line
  • equal - equal is a comparison operator used to compare one or more files
  • ~variable_name - anything followed by a ~ is interpreted as a configuration variable provided by the user

The keywords for writing configurations

  • $cliusage - a string containing the command line arguments of the program being run
  • :v - a shorthand notation for the previous user-defined configuration variable.

Here is a simple feature extracted from our sister project Nila:

Feature: Compiling a single line nila program
  Scenario: Input with a single line nila program
    Given the input file "simple.nila"
    When the ~compiler is run
    The output file must be "simple.js"
    The output file must equal "correct.js"

Configurations:

~compiler => bin/nilac.rb
:v $cliusage => ruby :v --compile $file

Usage

To initialize Shark in a project:

Shark -i

A new folder named Shark should have been added to your project. Inside the Sharkfolder, you will have two other folders named features and test_files. You should put all of your feature files into the features directory and all of your files for testing into the test_files directory. This is very important because Shark will automatically look into these directories to access those files.

To start testing go back to the main project directory and run:

Shark -t

Shortcomings/TODO

Currently there are several shortcomings in this project

  • Files mentioned in the features must exist or else the tool will stop. We will try to fix this problem as soon as possible.
  • Limited number of operators for file comparison. The only operator built into the system is the equality operator. Please post an issue if you need any additional operators.
Clone this wiki locally