Skip to content

Commit de35754

Browse files
committed
Fixed bootstrap header (fixes #324) and added test-protocol
1 parent 57bf7af commit de35754

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

misc/bootstrap_tester/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM ubuntu
2+
3+
4+
5+
RUN apt-get update
6+
RUN apt-get install -y zip
7+
RUN apt-get install -y curl

misc/bootstrap_tester/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Test Protocol for Bootstrap Header
2+
3+
```bash
4+
cd $KSCRIPT_HOME/misc/bootstrap_tester
5+
docker build -t bstester .
6+
7+
echo "println(42)" >> bs_test.kts
8+
9+
# Enrich the script with a bootstrap header
10+
export PATH=${KSCRIPT_HOME}/build/libs:${PATH}
11+
which kscript
12+
#kscript --help
13+
14+
kscript --add-bootstrap-header bs_test.kts
15+
cat bs_test.kts
16+
17+
# spin up the container to test the
18+
#docker run --rm -v ${PWD}:/apps -it ubuntu
19+
docker run --rm -v ${PWD}:/apps -it bstester
20+
```
21+
22+
Within the container run
23+
```bash
24+
cd /apps
25+
bash bs_test.kts
26+
27+
```

src/main/kotlin/kscript/app/Kscript.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private val BOOTSTRAP_HEADER = """
6767
6868
//usr/bin/env echo '
6969
/**** BOOTSTRAP kscript ****\'>/dev/null
70-
command -v kscript >/dev/null 2>&1 || curl -L "https://git.io/fpF1K" | bash 1>&2
70+
command -v kscript >/dev/null 2>&1 || source /dev/stdin <<< "${'$'}(curl -L https://git.io/fpF1K)"
7171
exec kscript $0 "$@"
7272
\*** IMPORTANT: Any code including imports and annotations must come after this line ***/
7373

test/TestsReadme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ export PATH=`echo ${PATH} | awk -v RS=: -v ORS=: '/kscript/ {next} {print}'`
7070

7171
For more examples see https://github.com/lehmannro/assert.sh/blob/master/tests.sh
7272

73+
## Bootstrap Header Testing
74+
75+
See [Test Protocol for Bootstrap Header](../misc/bootstrap_tester/README.md)
7376

7477
## Tests for dynamic dependencies
7578

0 commit comments

Comments
 (0)