Skip to content

CurlyBrackets/FunctionalTester

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FunctionalTester

##Types

  • Void/None

    Returned from commands that don't have meaningful results

  • Integer

    Pretty much what you'd expect

  • Boolean

    true or false

  • String

    Standard quoted strings with escape sequences

  • Multiline string

    A string bookended with """ that will contain exactly everything between those. Example:

    """ this is a
    test
    """
    

    will return this is a\ntest\n

  • Process

    A representation of a process, generated by the run and ssh commands

  • SSH Connection

    Hopefully it's pretty clear what this is

Commands

  • equal <something> <another thing> -> boolean

    Check if two things are equal

  • output <process> -> string

    Returns the output of a process

  • wait <process> [process [process] ...] -> void

    Wait for many processes to exit.

  • run <string> [string] -> process

    Run a command locally with optional arguments

  • shell <string> -> void

    Run a command synchrously in the shell

  • connect <string> [string] -> sshconn

    Connect to a server and provide an optional prefix. Commands run over an SSH connection are run in non-interative mode which means files like ~/.bash_profile or ~/.bashrc won't be run. This is where you'd source them. Another note about this is that it must have an accopanying disconnect command at some point otherwise temporary files will be left on the remote. Authentication information is stored securely using Triple DES and some other stuff (as part of a builtin library), so cached login info is safe.

  • disconnect <sshconn> [bool] -> void

    Disconnect from an ssh connection and optionally disable cleanup of files for debugging. Files will be moved into the home directory in a timestamped folder referencing the tests run.

  • ssh <sshconn> <string> -> process

    Run an command on an SSH server

  • scp <sshconn> <string> [string] -> void

    Transfer a file to an SSH server. First string arg is the local file and second, optional string arg is the remote file

  • read <filename> -> string

    Read a file into a string

  • write <filename> <content> -> void

    Write content to a file named filename

  • osswitch <unix value> <windows value> -> type of which ever value

    Select either unix value of windows value depending on the platform. Useful for error messages. The values do NOT need to be the same type.

Making Functions

Functions are run at the top level and are specified by square braces followed by a number of statements.

[Function]
  a = 5
  b = 5
  assert equal a b

Function names have special meaning; functions starting with Test are run as tests, functions named PreRun and PostRun are run before and after tests respectively. Statements that make up the body of a function and are separated by newlines. They can take several forms:

  • Assignment

    Assign the result of a command or a literal to an identifier that can be used later in the function. Identifiers defined in the PreRun function are available to all tests and the PostRun function.

  • Command

    Commands can just be on their own line and the result will be discarded. Particularily useful for commands that return void

  • Assert

    Assertions check the result of a boolean command and will stop execution of a test if it is false.

Globals

If an expression needs to be available to multiple functions or just looks better outside a function, a global can be defined in the form:

{VariableName} = some value

Examples

[PreRun]
  a = 5
[TestNumbers]
  b = 5
  assert equal a b
  assert equal a 77
[PreRun]
	thetis = connect "thetis.ugrad.cs.ubc.ca" "source ~/.bash_profile; "
[PostRun]
	disconnect thetis
[TestHello]
	scp thetis "tests/sanity/hello.go"
	p = ssh thetis "go build hello.go"
	wait p
	assert equal (output p) ""
	p2 = ssh thetis "./hello"
	wait p2
	assert equal (output p2) "Hello world\n"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published