Cmd: auto switch to heredoc if bash detected

This commit is contained in:
jpic 2020-01-31 21:56:37 +01:00
parent 0408590c4f
commit 6ad388fc5c
2 changed files with 39 additions and 10 deletions

View File

@ -8,6 +8,7 @@ from podctl.visitors import (
Base,
Copy,
Packages,
Run,
User,
)
@ -77,13 +78,14 @@ def test_build_copy():
)
'''
def test_build_files():
result = str(BuildScript(Container(
base='alpine',
files=[
Directory('/app', '0500').add('setup.py', 'podctl'),
]
)))
'''
def test_build_run():
script_test(
'build_run',
Base('alpine'),
Run('foo'),
Run('sudo bar'),
Run('sudo bar > test'),
Run('''
bar
'''),
)

27
tests/test_build_run.sh Normal file
View File

@ -0,0 +1,27 @@
#/usr/bin/env bash
base="alpine"
repo="None"
mounts=()
umounts() {
for i in "${mounts[@]}"; do
umount $i
mounts=("${mounts[@]/$i}")
done
buildah unmount $ctr
trap - 0
}
trap umounts 0
ctr=$(buildah from $base)
mnt=$(buildah mount $ctr)
echo "Run.build"
buildah run $ctr -- foo
echo "Run.build"
buildah run --user root $ctr -- bar
echo "Run.build"
buildah run --user root $ctr -- bash -eux <<__EOF
bar > test
__EOF
echo "Run.build"
buildah run $ctr -- bash -eux <<__EOF
bar
__EOF