Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .shellspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--require spec_helper

## Default kcov (coverage) options
# --kcov-options "--include-path=. --path-strip-level=1"
# --kcov-options "--include-pattern=.sh"
# --kcov-options "--exclude-pattern=/.shellspec,/spec/,/coverage/,/report/"

## Example: Include script "myprog" with no extension
# --kcov-options "--include-pattern=.sh,myprog"

## Example: Only specified files/directories
# --kcov-options "--include-pattern=myprog,/lib/"
56 changes: 56 additions & 0 deletions installers/gcloud/script.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/expect -f
#
# This Expect script was generated by autoexpect on Tue May 12 18:50:18 2020
# Expect and autoexpect were both written by Don Libes, NIST.
#
# Note that autoexpect does not guarantee a working script. It
# necessarily has to guess about certain things. Two reasons a script
# might fail are:
#
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
# etc.) and devices discard or ignore keystrokes that arrive "too
# quickly" after prompts. If you find your new script hanging up at
# one spot, try adding a short sleep just before the previous send.
# Setting "force_conservative" to 1 (see below) makes Expect do this
# automatically - pausing briefly before sending each character. This
# pacifies every program I know of. The -c flag makes the script do
# this in the first place. The -C flag allows you to define a
# character to toggle this mode off and on.

set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}

#
# 2) differing output - Some programs produce different output each time
# they run. The "date" command is an obvious example. Another is
# ftp, if it produces throughput statistics at the end of a file
# transfer. If this causes a problem, delete these patterns or replace
# them with wildcards. An alternative is to use the -p flag (for
# "prompt") which makes Expect only look for the last line of output
# (i.e., the prompt). The -P flag allows you to define a character to
# toggle this mode off and on.
#
# Read the man page for more info.
#
# -Don


set timeout -1
spawn ./installer.sh
match_max 100000
expect -exact "Installation directory (this will create a google-cloud-sdk subdirectory) (/root): "
send -- "\r"
expect -exact "Do you want to help improve the Google Cloud SDK (y/N)? "
send -- "N\r"
expect -exact "Do you want to continue (Y/n)? "
send -- "y\r"
expect -exact "\[/root/.bashrc\]: "
send -- "\r"
expect eof
10 changes: 10 additions & 0 deletions installers/gcloud/spec/gcloud_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Describe "Installer script for"
setup() { ./test.sh; }
Before 'setup'
Describe "gcloud"
It "should install with curl"
When call bash -c "gcloud --version"
The output should include "Google Cloud SDK"
End
End
End
8 changes: 8 additions & 0 deletions installers/gcloud/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

install (){
echo testing
#. ./script.exp
echo Bashing
#. ~/.bashrc
}
8 changes: 8 additions & 0 deletions spec/installer.to_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Describe "Root specfile"
Describe "try"
It "curl and get HTTP 200"
When call curl -s -o /dev/null -w "%{http_code}" https://installer.to
The output should eq "200"
End
End
End
7 changes: 7 additions & 0 deletions spec/spec_helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#shellcheck shell=sh

# set -eu

# shellspec_spec_helper_configure() {
# shellspec_import 'support/custom_matcher'
# }
4 changes: 1 addition & 3 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#!/bin/bash

#declare -a X
X=()

for word in "$@"; do
# echo $(dirname "$word")
X+=$(dirname "$word " | cut -d "/" -f "1 2")" "
done

CHANGED=$(echo $X | tr ' ' '\n' | sort | uniq | xargs)

echo "Running tests on $CHANGED"
shellspec $CHANGED -f d
shellspec $CHANGED