#!/bin/bash # # Sandstorm - Personal Cloud Sandbox # Copyright (c) 2014 Sandstorm Development Group, Inc. and contributors # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -euo pipefail global THIS_DIR := $[dirname $[readlink -f $(BASH_SOURCE[0])]] cd $THIS_DIR ../shell/test-packages.sh -f export SANDSTORM_DIR="$(SANDSTORM_DIR:-/opt/sandstorm)" test -e assets/ssjekyll5.spk || curl https://sandstorm.io/apps/ssjekyll5.spk > assets/ssjekyll5.spk test -e assets/ssjekyll6.spk || curl https://sandstorm.io/apps/ssjekyll6.spk > assets/ssjekyll6.spk test -e assets/ssjekyll7.spk || curl https://sandstorm.io/apps/ssjekyll7.spk > assets/ssjekyll7.spk if test ! -z $(TESTCASE:-) { # This is awkward because the test case name usually has spaces, but we need # to pass it as a single argument on the command-line. So, we concoct a bash # array with TESTNAME containin the name, spacing and all. read TESTFILE TESTNAME <<< $TESTCASE if test -z $TESTNAME { global NIGHTWATCH_PARAMS := '('-t $TESTFILE) } else { global NIGHTWATCH_PARAMS := '('-t $TESTFILE --testcase "$TESTNAME") } global SKIP_UNITTESTS := 'true' } if [[ -z "${LAUNCH_URL:-}" ]] { if [[ -z "${SKIP_UNITTESTS:-}" ]] { nightwatch -e unittests $(NIGHTWATCH_PARAMS[@]:-) } nightwatch -e default $(NIGHTWATCH_PARAMS[@]:-) } else { sed "s|.*launch_url.*|\"launch_url\" : \"$LAUNCH_URL\",|g" nightwatch.json > nightwatch.tmp.json if [[ -z "${SKIP_UNITTESTS:-}" ]] { nightwatch -e unittests -c ./nightwatch.tmp.json $(NIGHTWATCH_PARAMS[@]:-) } nightwatch -e default -c ./nightwatch.tmp.json $(NIGHTWATCH_PARAMS[@]:-) } (CommandList children: [ (C {(set)} {(-euo)} {(pipefail)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:THIS_DIR) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(dirname)} { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(readlink)} {(-f)} { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr:(ArithWord w:{(Lit_Digits 0)})) spids: [70 75] ) ) } ) ] ) left_token: spids: [64 77] ) ) } ) ] ) left_token: spids: [60 79] ) } spids: [59] ) ] spids: [59] ) (C {(cd)} {(DQ ($ VSub_Name "$THIS_DIR"))}) (C {(../shell/test-packages.sh)} {(-f)}) (C {(export)} {(Lit_VarLike "SANDSTORM_DIR=") (DQ (BracedVarSub token: suffix_op: (StringUnary op_id: VTest_ColonHyphen arg_word: {(Lit_Slash /) (opt) (Lit_Slash /) (sandstorm)} ) spids: [97 104] ) ) } ) (AndOr children: [ (C {(test)} {(-e)} {(assets/ssjekyll5.spk)}) (SimpleCommand words: [{(curl)} {(https) (Lit_Other ":") (//sandstorm.io/apps/ssjekyll5.spk)}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(assets/ssjekyll5.spk)} spids:[122])] ) ] op_id: Op_DPipe ) (AndOr children: [ (C {(test)} {(-e)} {(assets/ssjekyll6.spk)}) (SimpleCommand words: [{(curl)} {(https) (Lit_Other ":") (//sandstorm.io/apps/ssjekyll6.spk)}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(assets/ssjekyll6.spk)} spids:[140])] ) ] op_id: Op_DPipe ) (AndOr children: [ (C {(test)} {(-e)} {(assets/ssjekyll7.spk)}) (SimpleCommand words: [{(curl)} {(https) (Lit_Other ":") (//sandstorm.io/apps/ssjekyll7.spk)}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(assets/ssjekyll7.spk)} spids:[158])] ) ] op_id: Op_DPipe ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(-z)} { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [172 175] ) ) } {(Lit_Other "]")} ) terminator: ) ] action: [ (SimpleCommand words: [{(read)} {(TESTFILE)} {(TESTNAME)}] redirects: [ (Redir op_id: Redir_TLess fd: -1 arg_word: {(DQ ($ VSub_Name "$TESTCASE"))} spids: [202] ) ] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-z)} {(DQ ($ VSub_Name "$TESTNAME"))} {(Lit_Other "]")}) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:NIGHTWATCH_PARAMS) op: Equal rhs: {(ArrayLiteralPart words:[{(-t)}{($ VSub_Name "$TESTFILE")}])} spids: [225] ) ] spids: [225] ) ] spids: [-1 222] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:NIGHTWATCH_PARAMS) op: Equal rhs: { (ArrayLiteralPart words: [ {(-t)} {($ VSub_Name "$TESTFILE")} {(--testcase)} {(DQ ($ VSub_Name "$TESTNAME"))} ] ) } spids: [236] ) ] spids: [236] ) ] spids: [233 250] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SKIP_UNITTESTS) op: Equal rhs: {(true)} spids: [253] ) ] spids: [253] ) ] spids: [-1 181] ) ] spids: [-1 256] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolUnary op_id: BoolUnary_z child: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [266 269] ) ) } ) ) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolUnary op_id: BoolUnary_z child: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [285 288] ) ) } ) ) terminator: ) ] action: [ (C {(nightwatch)} {(-e)} {(unittests)} { (DQ (BracedVarSub token: bracket_op: (WholeArray op_id:Lit_At) suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [304 310] ) ) } ) ] spids: [-1 294] ) ] spids: [-1 314] ) (C {(nightwatch)} {(-e)} {(default)} { (DQ (BracedVarSub token: bracket_op: (WholeArray op_id:Lit_At) suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [324 330] ) ) } ) ] spids: [-1 275] ) ] else_action: [ (SimpleCommand words: [ {(sed)} { (DQ ("s|.*launch_url.*|") (EscapedLiteralPart token:) (launch_url) (EscapedLiteralPart token:) (" : ") (EscapedLiteralPart token:) ($ VSub_Name "$LAUNCH_URL") (EscapedLiteralPart token:) (",|g") ) } {(nightwatch.json)} ] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(nightwatch.tmp.json)} spids:[352])] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolUnary op_id: BoolUnary_z child: { (DQ (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [364 367] ) ) } ) ) terminator: ) ] action: [ (C {(nightwatch)} {(-e)} {(unittests)} {(-c)} {(./nightwatch.tmp.json)} { (DQ (BracedVarSub token: bracket_op: (WholeArray op_id:Lit_At) suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [387 393] ) ) } ) ] spids: [-1 373] ) ] spids: [-1 397] ) (C {(nightwatch)} {(-e)} {(default)} {(-c)} {(./nightwatch.tmp.json)} { (DQ (BracedVarSub token: bracket_op: (WholeArray op_id:Lit_At) suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(SQ )}) spids: [411 417] ) ) } ) ] spids: [333 420] ) ] )