This is a prototype for doing shell tests. To run:
$ ./test/suite.sh
To add another test suite, make a script in the test directory that ends with
-- sqlplus -s @ pkg.sql | |
set serverout on | |
create or replace package example | |
is | |
procedure hello (thing in varchar2); | |
end example; | |
/ | |
create or replace package body example |
class Agent | |
attr_reader :stdin | |
attr_reader :stdout | |
def initialize(stdin, stdout) | |
@stdin = stdin | |
@stdout = stdout | |
end | |
def run(inputs, max_run_time=nil) |
require 'pty' | |
require 'test/unit' | |
# See also: | |
# * http://stackoverflow.com/questions/3874604/pty-spawn-child-exit-code/7263243#7263243 | |
# * http://redmine.ruby-lang.org/issues/5253 | |
class PTYTest < Test::Unit::TestCase | |
def setup | |
system "true" | |
assert_equal 0, $?.exitstatus |
require 'pty' | |
require 'expect' | |
def shellout(shell, *lines) | |
prompt = /^(?:#{Regexp.escape(ENV['PS1'])}|#{Regexp.escape(ENV['PS2'])})/ | |
lines << 'exit' | |
PTY.spawn(shell) do |stdin,stdout,pid| | |
begin | |
lines.each do |line| |
require 'test/unit' | |
# Without warnings: | |
# | |
# $ ruby example_test.rb | |
# Loaded suite example_test | |
# Started | |
# . | |
# Finished in 0.000437 seconds. | |
# |
chiangs:~/Documents/Gems/rbenv>time rake start | |
$ VBoxManage -q controlvm abox poweroff | |
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% | |
$ VBoxManage -q controlvm bbox poweroff | |
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% | |
$ VBoxManage -q snapshot abox restore CURRENT | |
Restoring snapshot 80fc03ef-de05-4ecb-a437-bb2bd92964ad | |
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% | |
$ VBoxManage -q startvm abox --type headless | |
Waiting for the VM to power on... |
# Notes: | |
# 1) The input format must be specified to prevent ssh from hanging | |
# 2) The full path to the script is required | |
# 3) An SSH server must be running on the Windows box, naturally. WinSSHD | |
# is free for personal, non-commercial use and worked for this example. | |
# See http://www.bitvise.com/winsshd | |
# | |
# You have to set the execution policy for scripts so that powershell has | |
# permissions to run the script. To do so, search for 'Powershell' under | |
# the Start menu. Then right-click and 'Run as administrator' so that you |
#!/bin/sh | |
###################################################################### | |
# Example usage of SNOW (Steganographic Nature Of Whitespace) | |
# http://www.darkside.com.au/snow/ | |
# | |
# See also: http://www.cabinetmagazine.org/issues/40/sherman.php | |
###################################################################### | |
if ! [ -d snow_example ] |
Here is a link to the file.