#!/usr/bin/env bash
# make this auto-runnable! 
# Little bootstrap bash script to run kick start expect-lite script
# Convert --parms to expect-lite param=value format
PARAMS=`echo $* | /bin/sed -r 's;--([a-z_-]+) ([0-9a-zA-Z_/-]+);\1=\2;g'`
echo $PARAMS
expect-lite  c=$0 el=expect-lite d=$PWD $PARAMS
exit $?
# How to use this expect-lite file, Lines that begin with:
#	'>' send to remote host, implies "wait for prompt"
#	'<' _MUST_ be received from the remote host, or this config script will fail
#	# are comment lines, and have no effect
#	; are printable (in stdout) comments, and have no other effect
#	@ change the expect timeout value
#	! Embedded Expect commands
#	? If statement, use format ?cond?action::else_action
# For more info see: expect-lite.html

#
# Masquerade Test
#	Becomes a self running executable with bash script in the beginning
#	Takes getopts-like parameters and converts to expect-lite parameters
#
#
#	Requires expect-lite version 3.1.4

#
#	Self Test Suite for expect-lite, use connect_method=ssh_key
#
#	NOTE: Not all tests will pass when running connect method=none
#		self_test_directives.txt & self_test_fork.txt will fail
#

@45
>
>
# default expect-lite app
$el=expect-lite
$test_host=localhost

######## Get PWD to pass to child tests
>echo $PWD
>pwd
+$pwd=\n(/[a-zA-Z0-9/_.-]+)

######## Get host to pass to child tests
# back door to get --r parameter
!if { $::expectlite::remote_host == "none" } { set ::expectlite::user_namespace(test_host) "none" }
>hostname
?if $test_host == none? :: +$test_host=\n([a-zA-Z0-9/_-]+)
$test_host=localhost


######## set defaults
$count=0
# number of tests to run
$max_test_count=7
$fail=0

$self_test0=self_test_conditional.txt
$self_test1=self_test_code_block.txt
$self_test2=self_test_math.txt 
$self_test3=self_test_var_deref.txt
$self_test4=self_test_basics.txt
$self_test5=self_self_ide_test.txt
$self_test6=self_test_fork.txt
$self_test7=self_self_directive_test.txt


%START_LOOP
	; ******************** start self test: $self_test$count ********************

	>$el r=$test_host c=$self_test$count el=$el test_host=$test_host d=$pwd 
	<Overall Result
	>echo $?
	<0
	+$count
?if $count <= $max_test_count ? %START_LOOP
>
>
>
; ******************** Self Tests Pass! ********************
>
# pau!

