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
570 changes: 285 additions & 285 deletions tests/Earthfile

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions tests/autocompletion/install/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test-bash-non-root-fallback-dir:
ARG path="/home/bambi/.local/share/bash-completion/completions"
RUN mkdir -p "$path"
USER bambi
DO --pass-args +RUN_EARTHLY
DO --pass-args +RUN_EARTHBUILD
RUN grep '^complete' "$path/earthly" && \
grep -i 'successfully enabled bash-completion' out.txt

Expand All @@ -22,7 +22,7 @@ test-bash-non-root-no-overwrite:
echo "can't touch this" > "$path/earthly" && \
md5sum "$path/earthly" > /tmp/sum
USER bambi
DO --pass-args +RUN_EARTHLY
DO --pass-args +RUN_EARTHBUILD
RUN md5sum /tmp/sum && \
grep -i 'bash-completion already present' out.txt

Expand All @@ -33,15 +33,15 @@ test-bash-non-root-custom-dir:
ARG path="$BASH_COMPLETION_USER_DIR/bash-completion/completions"
RUN mkdir -p "$path"
USER bambi
DO --pass-args +RUN_EARTHLY
DO --pass-args +RUN_EARTHBUILD
RUN grep '^complete' "$path/earthly" && grep -i 'successfully enabled bash-completion' out.txt

test-bash-non-root-xdg-dir:
ENV XDG_DATA_HOME=/home/bambi/weird/xdg
ARG path="$XDG_DATA_HOME/bash-completion/completions"
RUN mkdir -p "$path"
USER bambi
DO --pass-args +RUN_EARTHLY
DO --pass-args +RUN_EARTHBUILD
RUN grep '^complete' "$path/earthly" && grep -i 'successfully enabled bash-completion' out.txt

test-bash-root-no-home-entries:
Expand All @@ -53,7 +53,7 @@ test-bash-root-no-home-entries:
mkdir -p /root/.local/share/bash-completion/completions
# for clarity
USER root
DO --pass-args +RUN_EARTHLY
DO --pass-args +RUN_EARTHBUILD
RUN test -z "$(find /root -name earthly -type f)"

test-all:
Expand All @@ -62,9 +62,9 @@ test-all:
BUILD +test-bash-non-root-xdg-dir
BUILD +test-bash-root-no-home-entries

RUN_EARTHLY:
RUN_EARTHBUILD:
FUNCTION
ARG exec_cmd=/tmp/bootstrap-script
DO ../../+RUN_EARTHLY \
DO ../../+RUN_EARTHBUILD \
--should_fail=false \
--exec_cmd=$exec_cmd
264 changes: 132 additions & 132 deletions tests/autoskip/Earthfile

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions tests/command-to-function-rename/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ test-calls-from-other-file:
RUN mkdir -p some/subdir
COPY caller.earth Earthfile
COPY command.earth some/subdir/Earthfile
DO --pass-args +RUN_EARTHLY_ARGS --target=+test-successful-command
DO --pass-args +RUN_EARTHBUILD_ARGS --target=+test-successful-command
COPY function.earth some/subdir/Earthfile
DO --pass-args +RUN_EARTHLY_ARGS --target=+test-successful-function
DO --pass-args +RUN_EARTHBUILD_ARGS --target=+test-successful-function

test-failed-calls:
WORKDIR /my/test
RUN mkdir -p some/subdir
COPY caller.earth Earthfile
COPY function.earth some/subdir/Earthfile
DO --pass-args +RUN_EARTHLY_ARGS --should_fail=true --target=+test-failed-command
DO --pass-args +RUN_EARTHBUILD_ARGS --should_fail=true --target=+test-failed-command
COPY command.earth some/subdir/Earthfile
DO --pass-args +RUN_EARTHLY_ARGS --should_fail=true --target=+test-failed-function
DO --pass-args +RUN_EARTHBUILD_ARGS --should_fail=true --target=+test-failed-function

RUN_EARTHLY_ARGS:
RUN_EARTHBUILD_ARGS:
COMMAND
ARG earthfile
ARG target
ARG should_fail=false
DO --pass-args tests+RUN_EARTHLY \
DO --pass-args tests+RUN_EARTHBUILD \
--earthfile=$earthfile \
--target=$target \
--should_fail=$should_fail
16 changes: 8 additions & 8 deletions tests/config/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ test:

# test earthly runs when no default config is present
RUN ! test -f /root/.earthly/config.yml
DO --pass-args +RUN_EARTHLY_ARGS --earthfile="hello.earth" --target="+hello" --output_contains="greetings"
DO --pass-args +RUN_EARTHBUILD_ARGS --earthfile="hello.earth" --target="+hello" --output_contains="greetings"

# test earthly can write to default config location
RUN earthly config global.cache_size_mb 10
RUN test "$(cat /root/.earthly/config.yml)" = "$(cat expected-1.yml)"

# test earthly fails when explicitly set to use a different config that doesn't exist
DO --pass-args +RUN_EARTHLY_ARGS --extra_args="--config=this-does-not-exist.yml" --earthfile="hello.earth" --target="+hello" --should_fail="true" --output_contains="failed to read from this-does-not-exist.yml"
DO --pass-args +RUN_EARTHBUILD_ARGS --extra_args="--config=this-does-not-exist.yml" --earthfile="hello.earth" --target="+hello" --should_fail="true" --output_contains="failed to read from this-does-not-exist.yml"

# test earthly runs with new cache percentage setting
RUN earthly config global.cache_size_pct 50
DO --pass-args +RUN_EARTHLY_ARGS --earthfile="hello.earth" --target="+hello" --output_contains="greetings"
DO --pass-args +RUN_EARTHBUILD_ARGS --earthfile="hello.earth" --target="+hello" --output_contains="greetings"

# test that it still runs alongside a size settings
RUN earthly config global.cache_size_mb 100
RUN test "$(cat /root/.earthly/config.yml)" = "$(cat expected-6.yml)"
DO --pass-args +RUN_EARTHLY_ARGS --earthfile="hello.earth" --target="+hello" --output_contains="greetings"
DO --pass-args +RUN_EARTHBUILD_ARGS --earthfile="hello.earth" --target="+hello" --output_contains="greetings"

RUN touch /tmp/config.yml
RUN chmod 400 /tmp/config.yml
Expand All @@ -68,10 +68,10 @@ test:
RUN addgroup -S testgroup
RUN adduser -S -G testgroup testuser

# required to allow testuser to call +RUN_EARTHLY_ARGS
# required to allow testuser to call +RUN_EARTHBUILD_ARGS
RUN chmod 0777 /tmp/earthbuild-script

# required to allow testuser to call +RUN_EARTHLY_ARGS
# required to allow testuser to call +RUN_EARTHBUILD_ARGS

USER testuser
WORKDIR /home/testuser
Expand Down Expand Up @@ -111,15 +111,15 @@ test:
RUN echo "config test passed"


RUN_EARTHLY_ARGS:
RUN_EARTHBUILD_ARGS:
FUNCTION
ARG earthfile
ARG target="+all"
ARG extra_args
ARG exec_cmd
ARG should_fail=false
ARG output_contains
DO --pass-args tests+RUN_EARTHLY \
DO --pass-args tests+RUN_EARTHBUILD \
--earthfile=$earthfile \
--target=$target \
--should_fail=$should_fail \
Expand Down
8 changes: 4 additions & 4 deletions tests/functions-do-not-propagate-args/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ test-all:
test-v07:
COPY propagate.earth Earthfile
RUN sed -i "s/VERSION_STRING_TO_REPLACE/VERSION --use-function-keyword 0.7/g" Earthfile
DO --pass-args +RUN_EARTHLY --target=+test --contains-output="A was not propagated"
DO --pass-args +RUN_EARTHBUILD --target=+test --contains-output="A was not propagated"

test-v08:
COPY propagate.earth Earthfile
RUN sed -i "s/VERSION_STRING_TO_REPLACE/VERSION 0.8/g" Earthfile
DO --pass-args +RUN_EARTHLY --target=+test --contains-output="A was not propagated"
DO --pass-args +RUN_EARTHBUILD --target=+test --contains-output="A was not propagated"

RUN_EARTHLY:
RUN_EARTHBUILD:
FUNCTION
DO --pass-args ..+RUN_EARTHLY
DO --pass-args ..+RUN_EARTHBUILD
6 changes: 3 additions & 3 deletions tests/git-metadata/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ EARTHLY_GIT_BRANCH_OVERRIDE=branch-override earthly --config \$earthly_config --
--build-arg flag_on=false \
git.example.com/testuser/repo/flag_off:main+test-git-metadata
" >/tmp/test-earthly-script && chmod +x /tmp/test-earthly-script
DO --pass-args +RUN_EARTHLY_ARGS --pre_command=start-sshd --exec_cmd=/tmp/test-earthly-script
DO --pass-args +RUN_EARTHBUILD_ARGS --pre_command=start-sshd --exec_cmd=/tmp/test-earthly-script

RUN_EARTHLY_ARGS:
RUN_EARTHBUILD_ARGS:
FUNCTION
ARG earthfile
ARG pre_command
ARG exec_cmd
DO ..+RUN_EARTHLY \
DO ..+RUN_EARTHBUILD \
--earthfile=$earthfile \
--pre_command=$pre_command \
--exec_cmd=$exec_cmd
26 changes: 13 additions & 13 deletions tests/git-ssh-server/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ rm -rf therepo3
earthly --config \$earthly_config --verbose -D +test
earthly --config \$earthly_config --verbose -D git.example.com/testuser/repo:main+hello
" >/tmp/test-earthly-script && chmod +x /tmp/test-earthly-script
DO --pass-args +RUN_EARTHLY_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script
DO --pass-args +RUN_EARTHBUILD_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script

test-ed25519-only:
FROM --pass-args ./setup+server \
Expand All @@ -66,7 +66,7 @@ ssh git@git.example.com | grep \"Hi git! You've successfully authenticated, but
earthly --config \$earthly_config --verbose -D +test
earthly --config \$earthly_config --verbose -D git.example.com/testuser/repo:main+hello
" >/tmp/test-earthly-script && chmod +x /tmp/test-earthly-script
DO --pass-args +RUN_EARTHLY_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script
DO --pass-args +RUN_EARTHBUILD_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script

test-server-both-user-rsa-only:
FROM --pass-args ./setup+server \
Expand All @@ -93,7 +93,7 @@ ssh git@git.example.com | grep \"Hi git! You've successfully authenticated, but
earthly --config \$earthly_config --verbose -D +test
earthly --config \$earthly_config --verbose -D git.example.com/testuser/repo:main+hello
" >/tmp/test-earthly-script && chmod +x /tmp/test-earthly-script
DO --pass-args +RUN_EARTHLY_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script
DO --pass-args +RUN_EARTHBUILD_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script

test-server-both-with-missing-keyscan:
FROM --pass-args ./setup+server \
Expand Down Expand Up @@ -128,7 +128,7 @@ if earthly --config \$earthly_config --verbose -D git.example.com/testuser/repo:
fi
cat output.txt | grep 'no known_hosts entries found for git.example.com; falling back to https'
" >/tmp/test-earthly-script && chmod +x /tmp/test-earthly-script
DO --pass-args +RUN_EARTHLY_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script
DO --pass-args +RUN_EARTHBUILD_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script

test-server-both-with-only-rsa-keyscan:
FROM --pass-args ./setup+server \
Expand Down Expand Up @@ -156,7 +156,7 @@ cat ~/.ssh/known_hosts
earthly --config \$earthly_config --verbose -D +test
earthly --config \$earthly_config --verbose -D git.example.com/testuser/repo:main+hello
" >/tmp/test-earthly-script && chmod +x /tmp/test-earthly-script
DO --pass-args +RUN_EARTHLY_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script
DO --pass-args +RUN_EARTHBUILD_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script

test-server-both-with-only-ed25519-keyscan:
FROM --pass-args ./setup+server \
Expand Down Expand Up @@ -184,7 +184,7 @@ cat ~/.ssh/known_hosts
earthly --config \$earthly_config --verbose -D +test
earthly --config \$earthly_config --verbose -D git.example.com/testuser/repo:main+hello
" >/tmp/test-earthly-script && chmod +x /tmp/test-earthly-script
DO --pass-args +RUN_EARTHLY_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script
DO --pass-args +RUN_EARTHBUILD_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script

test-configured-ssh-no-keyscan:
FROM --pass-args ./setup+server \
Expand Down Expand Up @@ -227,7 +227,7 @@ earthly --config \$earthly_config config 'git.\"git.example.com\"' '{\"auth\": \
earthly --config \$earthly_config --verbose -D +test
earthly --config \$earthly_config --verbose -D git.example.com/testuser/repo:main+hello
" >/tmp/test-earthly-script && chmod +x /tmp/test-earthly-script
DO --pass-args +RUN_EARTHLY_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script
DO --pass-args +RUN_EARTHBUILD_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script

test-server-with-unhashed-keyscan:
FROM --pass-args ./setup+server \
Expand Down Expand Up @@ -257,7 +257,7 @@ cat /tmp/known_hosts.old | awk '{printf \"git.example.com %s %s\\n\", \$2, \$3}'
earthly --config \$earthly_config --verbose -D +test
earthly --config \$earthly_config --verbose -D git.example.com/testuser/repo:main+hello
" >/tmp/test-earthly-script && chmod +x /tmp/test-earthly-script
DO --pass-args +RUN_EARTHLY_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script
DO --pass-args +RUN_EARTHBUILD_ARGS --pre_command=start-sshd --earthfile=git-clone-private-ssh.earth --exec_cmd=/tmp/test-earthly-script

test-with-custom-matcher:
FROM --pass-args ./setup+server \
Expand Down Expand Up @@ -304,7 +304,7 @@ cat output.txt | grep $(echo MTIzM2MwODQtNGNmNS00Nzk3LWE0YzUtZWI2NTM1NGVlN2Vl |
earthly --config \$earthly_config --verbose -D funnyserver/repo:main+hello 2>&1 | tee output.txt
cat output.txt | grep $(echo MTIzM2MwODQtNGNmNS00Nzk3LWE0YzUtZWI2NTM1NGVlN2Vl | base64 -d)
" >/tmp/test-earthly-script && chmod +x /tmp/test-earthly-script
DO --pass-args +RUN_EARTHLY_ARGS --pre_command=start-sshd --earthfile=from-funnyserver.earth --exec_cmd=/tmp/test-earthly-script
DO --pass-args +RUN_EARTHBUILD_ARGS --pre_command=start-sshd --earthfile=from-funnyserver.earth --exec_cmd=/tmp/test-earthly-script

test-git-clone-command-with-custom-matcher:
FROM --pass-args ./setup+server \
Expand Down Expand Up @@ -333,7 +333,7 @@ ssh-add -l
test \"\$(cat status)\" = \"0\"
grep 57043e67e8ad8367799dd70c5f78ff42 output.txt
" >/tmp/test-earthly-script && chmod +x /tmp/test-earthly-script
DO --pass-args +RUN_EARTHLY_ARGS --pre_command=start-sshd --earthfile=git-clone-funnyserver.earth --exec_cmd=/tmp/test-earthly-script
DO --pass-args +RUN_EARTHBUILD_ARGS --pre_command=start-sshd --earthfile=git-clone-funnyserver.earth --exec_cmd=/tmp/test-earthly-script

test-custom-matcher-non-standard-port-and-no-host-checking:
FROM --pass-args ./setup+server \
Expand Down Expand Up @@ -373,7 +373,7 @@ grep 57043e67e8ad8367799dd70c5f78ff42 output2.txt
# finally make sure we can reference it remotely via the cli
earthly --config \$earthly_config --verbose -D git.example.com/testuser/repo+hello
" >/tmp/test-earthly-script && chmod +x /tmp/test-earthly-script
DO --pass-args +RUN_EARTHLY_ARGS --pre_command=start-sshd --earthfile=git-clone-self-hosted.earth --exec_cmd=/tmp/test-earthly-script
DO --pass-args +RUN_EARTHBUILD_ARGS --pre_command=start-sshd --earthfile=git-clone-self-hosted.earth --exec_cmd=/tmp/test-earthly-script


all:
Expand All @@ -389,12 +389,12 @@ all:
BUILD +test-git-clone-command-with-custom-matcher
BUILD +test-custom-matcher-non-standard-port-and-no-host-checking

RUN_EARTHLY_ARGS:
RUN_EARTHBUILD_ARGS:
FUNCTION
ARG earthfile
ARG pre_command
ARG exec_cmd
DO ..+RUN_EARTHLY \
DO ..+RUN_EARTHBUILD \
--earthfile=$earthfile \
--pre_command=$pre_command \
--exec_cmd=$exec_cmd
8 changes: 4 additions & 4 deletions tests/invalid/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ IMPORT .. AS tests
WORKDIR /test

test-trailing-backslash:
DO --pass-args +RUN_EARTHLY_ARGS --earthfile=trailing-backslash.earth --should_fail=true --target=+base
DO --pass-args +RUN_EARTHBUILD_ARGS --earthfile=trailing-backslash.earth --should_fail=true --target=+base

test-leading-whitespace:
DO --pass-args +RUN_EARTHLY_ARGS --earthfile=leading-whitespace.earth --should_fail=true --target=+base --output_contains="syntax error"
DO --pass-args +RUN_EARTHBUILD_ARGS --earthfile=leading-whitespace.earth --should_fail=true --target=+base --output_contains="syntax error"

test-all:
BUILD +test-trailing-backslash
BUILD +test-leading-whitespace

RUN_EARTHLY_ARGS:
RUN_EARTHBUILD_ARGS:
FUNCTION
ARG earthfile
ARG target
ARG should_fail=false
ARG output_contains
DO --pass-args tests+RUN_EARTHLY \
DO --pass-args tests+RUN_EARTHBUILD \
--earthfile=$earthfile \
--target=$target \
--should_fail=$should_fail \
Expand Down
14 changes: 7 additions & 7 deletions tests/locally-in-command/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ test-command-in-sub-dir:
COPY target-that-calls-command.earth /the-test/Earthfile
COPY other-target-that-calls-command.earth /the-test/other/path/Earthfile
RUN touch /this-file-exists-locally
DO --pass-args +RUN_EARTHLY_ARGS --target=/the-test+test
DO --pass-args +RUN_EARTHBUILD_ARGS --target=/the-test+test
RUN test "$(cat /the-test/data)" = "I am running in /the-test"
DO --pass-args +RUN_EARTHLY_ARGS --target=/the-test+test --should-fail=true
DO --pass-args +RUN_EARTHBUILD_ARGS --target=/the-test+test --should-fail=true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The argument --should-fail is passed with a hyphen, but the function RUN_EARTHBUILD_ARGS defines the parameter as should_fail with an underscore. This mismatch will prevent the argument from being bound correctly, causing it to default to false and potentially leading to incorrect test assertions.

    DO --pass-args +RUN_EARTHBUILD_ARGS --target=/the-test+test --should_fail=true


# cleanup
RUN rm /the-test/data
RUN find /the-test | grep -v data

# next test a target that calls the same UDC from a different location
DO --pass-args +RUN_EARTHLY_ARGS --target=/the-test+test-other
DO --pass-args +RUN_EARTHBUILD_ARGS --target=/the-test+test-other
RUN ! test -f /the-test/data
RUN test "$(cat /the-test/other/path/data)" = "I am running in /the-test/other/path"

Expand All @@ -34,7 +34,7 @@ test-command-in-sub-dir:
RUN find /the-test | grep -v data

# finally test both targets that call the same locally command result in both files being created
DO --pass-args +RUN_EARTHLY_ARGS --target=/the-test+test-both
DO --pass-args +RUN_EARTHBUILD_ARGS --target=/the-test+test-both
RUN test "$(cat /the-test/data)" = "I am running in /the-test"
RUN test "$(cat /the-test/other/path/data)" = "I am running in /the-test/other/path"

Expand All @@ -44,15 +44,15 @@ test-udc-that-calls-other-udc:
COPY command.earth some/subdir/Earthfile
COPY command-that-calls-command.earth some/subdir/submarine/Earthfile
COPY target-that-calls-command-that-calls-command.earth Earthfile
DO --pass-args +RUN_EARTHLY_ARGS --target=+test
DO --pass-args +RUN_EARTHBUILD_ARGS --target=+test
RUN test "$(cat data)" = "I am running in /my/test"

RUN_EARTHLY_ARGS:
RUN_EARTHBUILD_ARGS:
FUNCTION
ARG earthfile
ARG target
ARG should_fail=false
DO --pass-args tests+RUN_EARTHLY \
DO --pass-args tests+RUN_EARTHBUILD \
--earthfile=$earthfile \
--target=$target \
--should_fail=$should_fail
Loading
Loading