From 4ac26772681d74be2cbbf9376a02ebc395257c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 17 May 2025 08:50:07 +0200 Subject: Initial test scripts and configuration --- test/asset/run/norepo-basic.yaml | 9 +++++ test/asset/run/repo-basic.yaml | 7 ++++ test/asset/run/repo-basic2.yaml | 15 +++++++++ test/script/run.et | 73 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 test/asset/run/norepo-basic.yaml create mode 100644 test/asset/run/repo-basic.yaml create mode 100644 test/asset/run/repo-basic2.yaml create mode 100644 test/script/run.et (limited to 'test') 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") -- cgit v1.2.3