diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2025-05-17 08:50:07 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-05-17 10:25:05 +0200 |
commit | 4ac26772681d74be2cbbf9376a02ebc395257c86 (patch) | |
tree | 16a140c9c245fbe1204c147ee6a6705dcb60601e /test | |
parent | c7930f132d1fff4fba0f8fbee6aa0edb38c40269 (diff) |
Initial test scripts and configuration
Diffstat (limited to 'test')
-rw-r--r-- | test/asset/run/norepo-basic.yaml | 9 | ||||
-rw-r--r-- | test/asset/run/repo-basic.yaml | 7 | ||||
-rw-r--r-- | test/asset/run/repo-basic2.yaml | 15 | ||||
-rw-r--r-- | test/script/run.et | 73 |
4 files changed, 104 insertions, 0 deletions
diff --git a/test/asset/run/norepo-basic.yaml b/test/asset/run/norepo-basic.yaml new file mode 100644 index 0000000..2000858 --- /dev/null +++ b/test/asset/run/norepo-basic.yaml @@ -0,0 +1,9 @@ +job success: + checkout: null + shell: + - "true" + +job failure: + checkout: null + shell: + - "false" diff --git a/test/asset/run/repo-basic.yaml b/test/asset/run/repo-basic.yaml new file mode 100644 index 0000000..82f5650 --- /dev/null +++ b/test/asset/run/repo-basic.yaml @@ -0,0 +1,7 @@ +job success: + shell: + - "true" + +job failure: + shell: + - "false" diff --git a/test/asset/run/repo-basic2.yaml b/test/asset/run/repo-basic2.yaml new file mode 100644 index 0000000..bcfac50 --- /dev/null +++ b/test/asset/run/repo-basic2.yaml @@ -0,0 +1,15 @@ +job success: + shell: + - "true" + +job third: + shell: + - "true" + +job failure: + shell: + - "false" + +job fourth: + shell: + - "true" diff --git a/test/script/run.et b/test/script/run.et new file mode 100644 index 0000000..4f4e016 --- /dev/null +++ b/test/script/run.et @@ -0,0 +1,73 @@ +module run + +asset scripts: + path: ../asset/run + +def expect_result from p of job result result: + let dummy = job == "" + expect from p: + /job-start $job/ + /job-finish $job ([a-z]+)/ capture done + guard (done == result) + + +test RunWithouRepo: + node n + spawn on n as p args [ "${scripts.path}/norepo-basic.yaml", "run", "success", "failure" ] + expect_result from p: + of "success" result "done" + of "failure" result "failed" + expect /(.*)/ from p capture done + guard (done == "run-finish") + + +test RunWithRepo: + node n + shell on n as git_init: + git -c init.defaultBranch=master init -q + git -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit' + git rev-parse HEAD + cp "${scripts.path}/repo-basic.yaml" minici.yaml + git add minici.yaml + git -c user.name=test -c user.email=test commit -q -m 'basic1' + git rev-parse HEAD^{tree} + cp "${scripts.path}/repo-basic2.yaml" minici.yaml + git add minici.yaml + git -c user.name=test -c user.email=test commit -q -m 'basic1' + git rev-parse HEAD + git rev-parse HEAD^{tree} + + expect /([0-9a-f]+)/ from git_init capture c0 + expect /([0-9a-f]+)/ from git_init capture t1 + expect /([0-9a-f]+)/ from git_init capture c2 + expect /([0-9a-f]+)/ from git_init capture t2 + + local: + spawn on n as p args [ "run", "--range=$c0..$c2" ] + expect_result from p: + of "$t1.success" result "done" + of "$t1.failure" result "failed" + + of "$t2.success" result "done" + of "$t2.failure" result "failed" + of "$t2.third" result "done" + of "$t2.fourth" result "done" + + expect /(.*)/ from p capture done + guard (done == "run-finish") + + local: + spawn on n as p args [ "./minici.yaml", "run", "--range=$c0..$c2" ] + expect_result from p: + of "$t1.success" result "done" + of "$t1.failure" result "failed" + of "$t1.third" result "done" + of "$t1.fourth" result "done" + + of "$t2.success" result "done" + of "$t2.failure" result "failed" + of "$t2.third" result "done" + of "$t2.fourth" result "done" + + expect /(.*)/ from p capture done + guard (done == "run-finish") |