diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/asset/artifact/minici.yaml | 25 | ||||
-rw-r--r-- | test/asset/run/dependencies.yaml | 55 | ||||
-rw-r--r-- | test/asset/run/explicit.yaml | 7 | ||||
-rw-r--r-- | test/asset/run/external.yaml | 42 | ||||
-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/artifact.et | 45 | ||||
-rw-r--r-- | test/script/repo.et | 89 | ||||
-rw-r--r-- | test/script/run.et | 295 |
10 files changed, 589 insertions, 0 deletions
diff --git a/test/asset/artifact/minici.yaml b/test/asset/artifact/minici.yaml new file mode 100644 index 0000000..7204bb3 --- /dev/null +++ b/test/asset/artifact/minici.yaml @@ -0,0 +1,25 @@ +job generate: + checkout: null + + shell: + - echo "content 1" > f1 + - mkdir -p dir/subdir + - echo "content 2" > dir/f2 + - echo "content a" > dir/fa + - echo "content b" > dir/subdir/fb + - echo "content 3" > f3 + + artifact first: + path: f1 + + artifact second: + path: dir/f2 + + artifact third: + path: f3 + + artifact dir: + path: dir + + artifact sdir: + path: dir/subdir diff --git a/test/asset/run/dependencies.yaml b/test/asset/run/dependencies.yaml new file mode 100644 index 0000000..7452b5a --- /dev/null +++ b/test/asset/run/dependencies.yaml @@ -0,0 +1,55 @@ +job first: + shell: + - touch x + + artifact out: + path: x + + +job second: + uses: + - first.out + + shell: + - mv x y + + artifact out: + path: y + + +job third: + uses: + - first.out + + shell: + - mv x z + + artifact out: + path: z + + +job fourth: + uses: + - second.out + + shell: + - mv y w + + artifact out: + path: w + + +job fifth: + uses: + - third.out + - fourth.out + + shell: + - mv z z2 + - mv w w2 + + artifact out1: + path: z2 + + artifact out2: + path: w2 diff --git a/test/asset/run/explicit.yaml b/test/asset/run/explicit.yaml new file mode 100644 index 0000000..d543d16 --- /dev/null +++ b/test/asset/run/explicit.yaml @@ -0,0 +1,7 @@ +job build: + shell: + - ls subdir | sed -e ':a;N;s/\n/ /;ta' > list + - echo >> list + + artifact out: + path: list diff --git a/test/asset/run/external.yaml b/test/asset/run/external.yaml new file mode 100644 index 0000000..f1d2b2c --- /dev/null +++ b/test/asset/run/external.yaml @@ -0,0 +1,42 @@ +repo first: + path: ../first + +repo second: + path: ../second + + +job single: + checkout: + repo: first + dest: first + + shell: + - tar czf first.tar.gz first + + artifact tarball: + path: ./first.tar.gz + +job multiple: + checkout: + - repo: first + dest: first-subdir + subtree: subdir + - repo: second + dest: second-subdir + subtree: sub + + shell: + - tar czf pack.tar.gz first-subdir second-subdir + + artifact tarball: + path: ./pack.tar.gz + +job combine: + checkout: null + + shell: + - ls + + uses: + - single.tarball + - multiple.tarball 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/artifact.et b/test/script/artifact.et new file mode 100644 index 0000000..c2bfc30 --- /dev/null +++ b/test/script/artifact.et @@ -0,0 +1,45 @@ +module artifact + +asset scripts: + path: ../asset/artifact + + +test ExtractArtifact: + node n + local: + spawn on n as p args [ "--storage=.minici", "${scripts.path}/minici.yaml", "run", "generate" ] + expect /job-finish generate done/ from p + + local: + spawn on n as p args [ "--storage=.minici", "${scripts.path}/minici.yaml", "extract", "generate.first", "extracted" ] + local: + shell on n as s: + cat ./extracted + expect /content 1/ from s + + local: + spawn on n as p args [ "--storage=.minici", "${scripts.path}/minici.yaml", "extract", "generate.second", "generate.third", "." ] + local: + shell on n as s: + cat ./f2 + cat ./f3 + expect /content 2/ from s + expect /content 3/ from s + + local: + spawn on n as p args [ "--storage=.minici", "${scripts.path}/minici.yaml", "extract", "generate.dir", "." ] + local: + shell on n as s: + cat ./dir/f2 + cat ./dir/fa + cat ./dir/subdir/fb + expect /content 2/ from s + expect /content a/ from s + expect /content b/ from s + + local: + spawn on n as p args [ "--storage=.minici", "${scripts.path}/minici.yaml", "extract", "generate.sdir", "extracted_subdir" ] + local: + shell on n as s: + cat ./extracted_subdir/fb + expect /content b/ from s diff --git a/test/script/repo.et b/test/script/repo.et new file mode 100644 index 0000000..d93f700 --- /dev/null +++ b/test/script/repo.et @@ -0,0 +1,89 @@ +test RepoSubtree: + node n + shell on n as git_init: + mkdir -p work + git -C work -c init.defaultBranch=master init -q + git -C work -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit' + + mkdir -p work/first/second + touch work/first/second/file + git -C work add first + git -C work -c user.name=test -c user.email=test commit -q -m 'commit' + git -C work rev-parse HEAD^{commit} + git -C work rev-parse HEAD^{tree} + git -C work rev-parse HEAD:first + git -C work rev-parse HEAD:first/second + + git clone -q --bare work bare.git + + expect /([0-9a-f]+)/ from git_init capture commit + expect /([0-9a-f]+)/ from git_init capture root + expect /([0-9a-f]+)/ from git_init capture sub1 + expect /([0-9a-f]+)/ from git_init capture sub2 + + for repo in [ "./work", "./bare.git" ]: + local: + spawn as p on n args [ repo, "subtree", commit, "" ] + expect from p /msg $root/ + expect from p /path (.*)/ capture path + guard (path == "") + + local: + spawn as p on n args [ repo, "subtree", commit, "." ] + expect from p /msg $root/ + expect from p /path (.*)/ capture path + guard (path == "") + + local: + spawn as p on n args [ repo, "subtree", commit, "/" ] + expect from p /msg $root/ + expect from p /path (.*)/ capture path + guard (path == "") + + local: + spawn as p on n args [ repo, "subtree", commit, "first" ] + expect from p /msg $sub1/ + expect from p /path (.*)/ capture path + guard (path == "first") + + local: + spawn as p on n args [ repo, "subtree", commit, "./first" ] + expect from p /msg $sub1/ + expect from p /path (.*)/ capture path + guard (path == "first") + + local: + spawn as p on n args [ repo, "subtree", commit, "/first" ] + expect from p /msg $sub1/ + expect from p /path (.*)/ capture path + guard (path == "first") + + local: + spawn as p on n args [ repo, "subtree", commit, "./first/second" ] + expect from p /msg $sub2/ + expect from p /path (.*)/ capture path + guard (path == "first/second") + + local: + spawn as p on n args [ repo, "subtree", commit, "/first/second" ] + expect from p /msg $sub2/ + expect from p /path (.*)/ capture path + guard (path == "first/second") + + local: + spawn as p on n args [ repo, "subtree", "$sub1(first)", "second" ] + expect from p /msg $sub2/ + expect from p /path (.*)/ capture path + guard (path == "first/second") + + local: + spawn as p on n args [ repo, "subtree", "$sub1(first)", "./second" ] + expect from p /msg $sub2/ + expect from p /path (.*)/ capture path + guard (path == "first/second") + + local: + spawn as p on n args [ repo, "subtree", "$sub1(first)", "/second/" ] + expect from p /msg $sub2/ + expect from p /path (.*)/ capture path + guard (path == "first/second") diff --git a/test/script/run.et b/test/script/run.et new file mode 100644 index 0000000..08cee71 --- /dev/null +++ b/test/script/run.et @@ -0,0 +1,295 @@ +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) + +def expect_success from p of job: + expect_result from p of job result "done" + + +test RunWithoutRepo: + node n + spawn on n as p args [ "--storage=.minici", "${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") + + +test RunExternalRepo: + node n + shell on n as git_init: + mkdir -p first/subdir + git -C first -c init.defaultBranch=master init -q + git -C first -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit' + touch first/subdir/file + git -C first add subdir + git -C first -c user.name=test -c user.email=test commit -q -m 'commit' + git -C first rev-parse HEAD^{tree} + git -C first rev-parse HEAD:subdir + + mkdir -p second/sub + git -C second -c init.defaultBranch=master init -q + git -C second -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit' + touch second/sub/other + git -C second add sub + git -C second -c user.name=test -c user.email=test commit -q -m 'commit' + git -C second rev-parse HEAD^{tree} + git -C second rev-parse HEAD:sub + + mkdir -p main + git -C main -c init.defaultBranch=master init -q + git -C main -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit' + cp "${scripts.path}/external.yaml" main/minici.yaml + git -C main add minici.yaml + git -C main -c user.name=test -c user.email=test commit -q -m 'commit' + git -C main rev-parse HEAD^{tree} + + expect /([0-9a-f]+)/ from git_init capture first_root + expect /([0-9a-f]+)/ from git_init capture first_subtree + expect /([0-9a-f]+)/ from git_init capture second_root + expect /([0-9a-f]+)/ from git_init capture second_subtree + expect /([0-9a-f]+)/ from git_init capture main_root + + # Explicit jobfile outside of any git repo + local: + spawn on n as p args [ "--repo=first:./first", "--repo=second:./second", "--storage=.minici", "${scripts.path}/external.yaml", "run", "single", "multiple", "combine" ] + for job in [ "single.$first_root", "multiple.$first_subtree.$second_subtree", "combine.$first_root.$second_subtree" ]: + expect_success from p of job + + expect /(.*)/ from p capture done + guard (done == "run-finish") + + # Explicit jobfile within a git repo + local: + spawn on n as p args [ "--repo=first:./first", "--repo=second:./second", "--storage=.minici", "${scripts.path}/external.yaml", "run", "single" ] + expect_success from p of "single.$first_root" + expect /(.*)/ from p capture done + guard (done == "run-finish") + + # Implicit jobfile within a git repo + local: + spawn on n as p args [ "--repo=first:./first", "--repo=second:./second", "./main", "run", "HEAD^..HEAD" ] + for job in [ "single.$first_root", "multiple.$first_subtree.$second_subtree", "combine.$first_root.$second_subtree" ]: + expect_success from p of "$main_root.$job" + + expect /(.*)/ from p capture done + guard (done == "run-finish") + + +test RunExplicitJob: + node n + shell on n as git_init: + mkdir -p main + git -C main -c init.defaultBranch=master init -q + cp "${scripts.path}/explicit.yaml" main/minici.yaml + git -C main add minici.yaml + git -C main -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit' + + mkdir -p main/subdir + + touch main/subdir/a + git -C main add subdir + git -C main -c user.name=test -c user.email=test commit -q -m 'commit' + git -C main rev-parse HEAD^{commit} + git -C main rev-parse HEAD^{tree} + + touch main/subdir/b + git -C main add subdir + git -C main -c user.name=test -c user.email=test commit -q -m 'commit' + git -C main rev-parse HEAD^{tree} + + rm main/subdir/a + rm main/subdir/b + touch main/subdir/c + git -C main add subdir + git -C main -c user.name=test -c user.email=test commit -q -m 'commit' + git -C main rev-parse HEAD^{tree} + + touch main/subdir/d + git -C main add subdir + git -C main -c user.name=test -c user.email=test commit -q -m 'commit' + git -C main rev-parse HEAD^{tree} + + expect /([0-9a-f]+)/ from git_init capture c1 + expect /([0-9a-f]+)/ from git_init capture t1 + expect /([0-9a-f]+)/ from git_init capture t2 + expect /([0-9a-f]+)/ from git_init capture t3 + expect /([0-9a-f]+)/ from git_init capture t4 + + local: + spawn on n as p args [ "./main", "run", "$c1.build" ] + expect_success from p of "$t1.build" + expect /(.*)/ from p capture done + guard (done == "run-finish") + local: + spawn on n as p args [ "./main", "extract", "$c1.build.out", "list" ] + local: + shell on n as s: + cat list + rm list + expect /a/ from s + + local: + spawn on n as p args [ "./main", "run", "$t2.build" ] + expect_success from p of "$t2.build" + expect /(.*)/ from p capture done + guard (done == "run-finish") + local: + spawn on n as p args [ "./main", "extract", "$t2.build.out", "list" ] + local: + shell on n as s: + cat list + rm list + expect /a b/ from s + + local: + spawn on n as p args [ "./main", "run", "HEAD^.build" ] + expect_success from p of "$t3.build" + expect /(.*)/ from p capture done + guard (done == "run-finish") + local: + spawn on n as p args [ "./main", "extract", "HEAD^.build.out", "list" ] + local: + shell on n as s: + cat list + rm list + expect /c/ from s + + local: + spawn on n as p args [ "./main", "run", "HEAD.build" ] + expect_success from p of "$t4.build" + expect /(.*)/ from p capture done + guard (done == "run-finish") + local: + spawn on n as p args [ "./main", "extract", "HEAD.build.out", "list" ] + local: + shell on n as s: + cat list + rm list + expect /c d/ from s + + +test RunExplicitDependentJob: + node n + shell on n as git_init: + mkdir -p main + git -C main -c init.defaultBranch=master init -q + cp "${scripts.path}/dependencies.yaml" main/minici.yaml + git -C main add minici.yaml + git -C main -c user.name=test -c user.email=test commit -q --allow-empty -m 'initial commit' + + mkdir -p main/subdir + + touch main/subdir/a + git -C main add subdir + git -C main -c user.name=test -c user.email=test commit -q -m 'commit' + git -C main rev-parse HEAD^{commit} + git -C main rev-parse HEAD^{tree} + + touch main/subdir/b + git -C main add subdir + git -C main -c user.name=test -c user.email=test commit -q -m 'commit' + git -C main rev-parse HEAD^{tree} + + rm main/subdir/a + rm main/subdir/b + touch main/subdir/c + git -C main add subdir + git -C main -c user.name=test -c user.email=test commit -q -m 'commit' + git -C main rev-parse HEAD^{tree} + + touch main/subdir/d + git -C main add subdir + git -C main -c user.name=test -c user.email=test commit -q -m 'commit' + git -C main rev-parse HEAD^{tree} + + expect /([0-9a-f]+)/ from git_init capture c1 + expect /([0-9a-f]+)/ from git_init capture t1 + expect /([0-9a-f]+)/ from git_init capture t2 + expect /([0-9a-f]+)/ from git_init capture t3 + expect /([0-9a-f]+)/ from git_init capture t4 + + local: + spawn on n as p args [ "./main", "run", "$c1.first", "$t2.first", "$t3.fourth", "$c1.fifth", "$c1.fourth", "$c1.third", "$c1.second", "$t4.fifth" ] + expect_success from p of "$t1.first" + expect_success from p of "$t1.second" + expect_success from p of "$t1.third" + expect_success from p of "$t1.fourth" + expect_success from p of "$t1.fifth" + + expect_success from p of "$t2.first" + + expect_success from p of "$t3.first" + expect_success from p of "$t3.second" + expect_success from p of "$t3.fourth" + + expect_success from p of "$t4.first" + expect_success from p of "$t4.second" + expect_success from p of "$t4.third" + expect_success from p of "$t4.fourth" + expect_success from p of "$t4.fifth" + + flush from p matching /note .*/ + expect /(.*)/ from p capture done + guard (done == "run-finish") |