Skip to content

Commit 48fdfb2

Browse files
Add tests for shell execution on artifacts build (#2884)
## Why This part of the codebase was missing test coverage. I plan on changing the execution of commands to inline the script content and these tests are required to ensure I don't break anything (relevant discussion: #2862 (comment)) --------- Co-authored-by: Denis Bilenko <denis.bilenko@databricks.com>
1 parent 2e90a77 commit 48fdfb2

30 files changed

Lines changed: 144 additions & 3 deletions
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
bundle:
2+
name: shell-bash
3+
4+
artifacts:
5+
my_artifact:
6+
executable: bash
7+
# echo in bash does not treat \n as a newline.
8+
build: |
9+
echo "\n\n\n should not see new lines" > out.shell.txt
10+
echo "multiline scripts should work" >> out.shell.txt
11+
pwd >> out.shell.txt
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
\n\n\n should not see new lines
2+
multiline scripts should work
3+
[TEST_TMP_DIR]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
>>> [CLI] bundle deploy
3+
Building my_artifact...
4+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/shell-bash/default/files...
5+
Deploying resources...
6+
Deployment complete!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
trace $CLI bundle deploy
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Line feed (\n) characters are rendered differently by bash vs sh on Unix based systems.
2+
# However that does not hold true for Windows WSL. Since the goal of this test is to assert
3+
# the chosen shell is being used, we skip this test on Windows.
4+
[GOOS]
5+
windows = false
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
bundle:
2+
name: shell-basic
3+
4+
artifacts:
5+
my_artifact:
6+
build: |
7+
echo "Hello, World!" > out.shell.txt
8+
echo "Bye, World!" >> out.shell.txt
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Hello, World!
2+
Bye, World!
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
>>> [CLI] bundle deploy
3+
Building my_artifact...
4+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/shell-basic/default/files...
5+
Deploying resources...
6+
Deployment complete!
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
trace $CLI bundle deploy
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
bundle:
2+
name: shell-cmd
3+
4+
artifacts:
5+
my_artifact:
6+
executable: cmd
7+
build: |
8+
if defined CMDCMDLINE (
9+
echo shell is cmd.exe> out.shell.txt
10+
)
11+
echo multiline scripts should work>> out.shell.txt
12+
echo %CD%>> out.shell.txt

0 commit comments

Comments
 (0)