From e560b420b814652c42f61fe03d2151d0f348469b Mon Sep 17 00:00:00 2001 From: zongz Date: Thu, 29 Feb 2024 19:42:05 +0800 Subject: [PATCH] feat: add more e2e test Signed-off-by: zongz --- .github/workflows/e2e-test.yml | 20 +++ cmd/kcl/commands/mod_init.go | 4 +- cmd/kcl/commands/mod_pkg.go | 4 +- cmd/kcl/commands/mod_push.go | 2 +- docs/dev-guide-e2e.md | 136 +++++++++++++++ go.mod | 36 ++-- go.sum | 67 +++++--- makefile | 8 + pkg/options/import.go | 2 +- scripts/e2e/e2e-init.sh | 25 +++ scripts/e2e/e2e.sh | 35 ++++ scripts/e2e/pkg_in_reg/kcl1/kcl.mod | 7 + scripts/e2e/pkg_in_reg/kcl1/kcl.mod.lock | 9 + scripts/e2e/pkg_in_reg/kcl1/main.k | 1 + scripts/e2e/pkg_in_reg/kcl2/kcl.mod | 5 + scripts/e2e/pkg_in_reg/kcl2/kcl.mod.lock | 0 scripts/e2e/pkg_in_reg/kcl2/main.k | 1 + scripts/e2e/pull_pkg.sh | 24 +++ scripts/e2e/push_pkg.sh | 33 ++++ scripts/e2e/reg.sh | 28 ++++ scripts/e2e/registry_auth/htpasswd | 2 + test/e2e/cli.go | 155 ++++++++++++++++++ test/e2e/e2e_suite_test.go | 38 +++++ test/e2e/kpm_test.go | 69 ++++++++ test/e2e/test_suite.go | 113 +++++++++++++ .../test_suites/test_kcl_mod_add_git/input | 1 + .../test_suites/test_kcl_mod_add_git/stderr | 0 .../test_suites/test_kcl_mod_add_git/stdout | 4 + .../test_kcl_mod_add_git/test_space/kcl.mod | 5 + .../test_space/kcl.mod.lock | 0 .../test_kcl_mod_add_git/test_space/main.k | 1 + .../test_kcl_mod_add_local/conf.json | 3 + .../test_suites/test_kcl_mod_add_local/input | 1 + .../test_suites/test_kcl_mod_add_local/stderr | 0 .../test_suites/test_kcl_mod_add_local/stdout | 2 + .../test_space/dep/kcl.mod | 5 + .../test_space/dep/kcl.mod.lock | 0 .../test_space/dep/main.k | 1 + .../test_space/pkg/kcl.mod | 5 + .../test_space/pkg/kcl.mod.lock | 0 .../test_space/pkg/main.k | 1 + .../test_kcl_mod_add_local_0/conf.json | 3 + .../test_kcl_mod_add_local_0/input | 1 + .../test_kcl_mod_add_local_0/stderr | 0 .../test_kcl_mod_add_local_0/stdout | 3 + .../test_space/dep/kcl.mod | 7 + .../test_space/dep/kcl.mod.lock | 9 + .../test_space/dep/main.k | 1 + .../test_space/pkg/kcl.mod | 5 + .../test_space/pkg/kcl.mod.lock | 0 .../test_space/pkg/main.k | 1 + .../test_suites/test_kcl_mod_add_oci/input | 1 + .../test_suites/test_kcl_mod_add_oci/stderr | 0 .../test_suites/test_kcl_mod_add_oci/stdout | 4 + .../test_kcl_mod_add_oci/test_space/kcl.mod | 5 + .../test_space/kcl.mod.lock | 0 .../test_kcl_mod_add_oci/test_space/main.k | 1 + .../test_suites/test_kcl_mod_add_oci_0/input | 1 + .../test_suites/test_kcl_mod_add_oci_0/stderr | 0 .../test_suites/test_kcl_mod_add_oci_0/stdout | 3 + .../test_kcl_mod_add_oci_0/test_space/kcl.mod | 5 + .../test_space/kcl.mod.lock | 0 .../test_kcl_mod_add_oci_0/test_space/main.k | 1 + .../test_suites/test_kcl_mod_add_oci_1/input | 1 + .../test_suites/test_kcl_mod_add_oci_1/stderr | 0 .../test_suites/test_kcl_mod_add_oci_1/stdout | 5 + .../test_kcl_mod_add_oci_1/test_space/kcl.mod | 5 + .../test_space/kcl.mod.lock | 0 .../test_kcl_mod_add_oci_1/test_space/main.k | 1 + test/e2e/test_suites/test_kcl_mod_init/input | 1 + test/e2e/test_suites/test_kcl_mod_init/stderr | 0 test/e2e/test_suites/test_kcl_mod_init/stdout | 4 + .../e2e/test_suites/test_kcl_mod_init_0/input | 1 + .../test_suites/test_kcl_mod_init_0/stderr | 0 .../test_suites/test_kcl_mod_init_0/stdout | 6 + .../test_space/kcl.mod.lock | 0 .../test_kcl_mod_init_0/test_space/main.k | 1 + .../e2e/test_suites/test_kcl_mod_init_1/input | 1 + .../test_suites/test_kcl_mod_init_1/stderr | 0 .../test_suites/test_kcl_mod_init_1/stdout | 7 + .../test_kcl_mod_init_1/test_space/kcl.mod | 5 + .../test_space/kcl.mod.lock | 0 .../test_kcl_mod_init_1/test_space/main.k | 1 + .../e2e/test_suites/test_kcl_mod_init_2/input | 1 + .../test_suites/test_kcl_mod_init_2/stderr | 0 .../test_suites/test_kcl_mod_init_2/stdout | 5 + .../test_kcl_mod_init_2/test_space/main.k | 1 + test/e2e/test_suites/test_kcl_mod_pkg/input | 1 + test/e2e/test_suites/test_kcl_mod_pkg/stderr | 0 test/e2e/test_suites/test_kcl_mod_pkg/stdout | 0 .../test_kcl_mod_pkg/test_space/kcl.mod | 5 + .../test_kcl_mod_pkg/test_space/kcl.mod.lock | 0 .../test_kcl_mod_pkg/test_space/main.k | 1 + test/e2e/test_suites/test_kcl_mod_pull/input | 1 + test/e2e/test_suites/test_kcl_mod_pull/stderr | 0 test/e2e/test_suites/test_kcl_mod_pull/stdout | 4 + .../e2e/test_suites/test_kcl_mod_pull_0/input | 1 + .../test_suites/test_kcl_mod_pull_0/stderr | 0 .../test_suites/test_kcl_mod_pull_0/stdout | 3 + .../e2e/test_suites/test_kcl_mod_pull_1/input | 1 + .../test_suites/test_kcl_mod_pull_1/stderr | 0 .../test_suites/test_kcl_mod_pull_1/stdout | 4 + test/e2e/test_suites/test_kcl_mod_push/input | 1 + test/e2e/test_suites/test_kcl_mod_push/stderr | 0 test/e2e/test_suites/test_kcl_mod_push/stdout | 3 + .../test_kcl_mod_push/test_space/kcl.mod | 5 + .../test_kcl_mod_push/test_space/kcl.mod.lock | 0 .../test_kcl_mod_push/test_space/main.k | 1 + .../e2e/test_suites/test_kcl_mod_push_0/input | 1 + .../test_suites/test_kcl_mod_push_0/stderr | 0 .../test_suites/test_kcl_mod_push_0/stdout | 3 + .../test_kcl_mod_push_0/test_space/kcl.mod | 5 + .../test_space/kcl.mod.lock | 0 .../test_kcl_mod_push_0/test_space/main.k | 1 + .../e2e/test_suites/test_kcl_mod_update/input | 1 + .../test_suites/test_kcl_mod_update/stderr | 0 .../test_suites/test_kcl_mod_update/stdout | 1 + .../test_kcl_mod_update/test_space/kcl.mod | 7 + .../test_kcl_mod_update/test_space/main.k | 1 + .../test_suites/test_kcl_mod_update_0/input | 1 + .../test_suites/test_kcl_mod_update_0/stderr | 0 .../test_suites/test_kcl_mod_update_0/stdout | 0 .../test_space/pkg/kcl.mod | 5 + .../test_space/pkg/main.k | 1 + test/e2e/test_suites/test_kcl_run/input | 1 + test/e2e/test_suites/test_kcl_run/stderr | 0 test/e2e/test_suites/test_kcl_run/stdout | 1 + .../test_kcl_run/test_space/main.k | 1 + test/e2e/test_suites/test_kcl_run_0/input | 1 + test/e2e/test_suites/test_kcl_run_0/stderr | 0 test/e2e/test_suites/test_kcl_run_0/stdout | 3 + .../test_kcl_run_0/test_space/main.k | 1 + test/e2e/test_suites/test_kcl_run_1/input | 1 + test/e2e/test_suites/test_kcl_run_1/stderr | 0 test/e2e/test_suites/test_kcl_run_1/stdout | 2 + .../test_kcl_run_1/test_space/run.k | 1 + .../test_kcl_run_1/test_space/run1.k | 1 + test/e2e/test_suites/test_kcl_run_2/input | 1 + test/e2e/test_suites/test_kcl_run_2/stderr | 0 test/e2e/test_suites/test_kcl_run_2/stdout | 3 + test/e2e/test_suites/test_kcl_run_3/input | 1 + test/e2e/test_suites/test_kcl_run_3/stderr | 0 test/e2e/test_suites/test_kcl_run_3/stdout | 1 + .../test_kcl_run_3/test_space/kcl.mod | 5 + .../test_kcl_run_3/test_space/kcl.mod.lock | 0 .../test_kcl_run_3/test_space/main.k | 1 + test/e2e/utils.go | 96 +++++++++++ 147 files changed, 1093 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/e2e-test.yml create mode 100644 docs/dev-guide-e2e.md create mode 100755 scripts/e2e/e2e-init.sh create mode 100755 scripts/e2e/e2e.sh create mode 100644 scripts/e2e/pkg_in_reg/kcl1/kcl.mod create mode 100644 scripts/e2e/pkg_in_reg/kcl1/kcl.mod.lock create mode 100644 scripts/e2e/pkg_in_reg/kcl1/main.k create mode 100644 scripts/e2e/pkg_in_reg/kcl2/kcl.mod create mode 100644 scripts/e2e/pkg_in_reg/kcl2/kcl.mod.lock create mode 100644 scripts/e2e/pkg_in_reg/kcl2/main.k create mode 100755 scripts/e2e/pull_pkg.sh create mode 100755 scripts/e2e/push_pkg.sh create mode 100755 scripts/e2e/reg.sh create mode 100644 scripts/e2e/registry_auth/htpasswd create mode 100644 test/e2e/cli.go create mode 100644 test/e2e/e2e_suite_test.go create mode 100644 test/e2e/kpm_test.go create mode 100644 test/e2e/test_suite.go create mode 100644 test/e2e/test_suites/test_kcl_mod_add_git/input create mode 100644 test/e2e/test_suites/test_kcl_mod_add_git/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_add_git/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_add_git/test_space/kcl.mod create mode 100644 test/e2e/test_suites/test_kcl_mod_add_git/test_space/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_kcl_mod_add_git/test_space/main.k create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local/conf.json create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local/input create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local/test_space/dep/kcl.mod create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local/test_space/dep/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local/test_space/dep/main.k create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local/test_space/pkg/kcl.mod create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local/test_space/pkg/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local/test_space/pkg/main.k create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local_0/conf.json create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local_0/input create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local_0/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local_0/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/dep/kcl.mod create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/dep/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/dep/main.k create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/pkg/kcl.mod create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/pkg/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/pkg/main.k create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci/input create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci/test_space/kcl.mod create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci/test_space/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci/test_space/main.k create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci_0/input create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci_0/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci_0/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci_0/test_space/kcl.mod create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci_0/test_space/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci_0/test_space/main.k create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci_1/input create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci_1/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci_1/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci_1/test_space/kcl.mod create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci_1/test_space/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_kcl_mod_add_oci_1/test_space/main.k create mode 100644 test/e2e/test_suites/test_kcl_mod_init/input create mode 100644 test/e2e/test_suites/test_kcl_mod_init/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_init/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_init_0/input create mode 100644 test/e2e/test_suites/test_kcl_mod_init_0/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_init_0/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_init_0/test_space/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_kcl_mod_init_0/test_space/main.k create mode 100644 test/e2e/test_suites/test_kcl_mod_init_1/input create mode 100644 test/e2e/test_suites/test_kcl_mod_init_1/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_init_1/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_init_1/test_space/kcl.mod create mode 100644 test/e2e/test_suites/test_kcl_mod_init_1/test_space/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_kcl_mod_init_1/test_space/main.k create mode 100644 test/e2e/test_suites/test_kcl_mod_init_2/input create mode 100644 test/e2e/test_suites/test_kcl_mod_init_2/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_init_2/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_init_2/test_space/main.k create mode 100644 test/e2e/test_suites/test_kcl_mod_pkg/input create mode 100644 test/e2e/test_suites/test_kcl_mod_pkg/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_pkg/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_pkg/test_space/kcl.mod create mode 100644 test/e2e/test_suites/test_kcl_mod_pkg/test_space/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_kcl_mod_pkg/test_space/main.k create mode 100644 test/e2e/test_suites/test_kcl_mod_pull/input create mode 100644 test/e2e/test_suites/test_kcl_mod_pull/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_pull/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_pull_0/input create mode 100644 test/e2e/test_suites/test_kcl_mod_pull_0/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_pull_0/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_pull_1/input create mode 100644 test/e2e/test_suites/test_kcl_mod_pull_1/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_pull_1/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_push/input create mode 100644 test/e2e/test_suites/test_kcl_mod_push/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_push/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_push/test_space/kcl.mod create mode 100644 test/e2e/test_suites/test_kcl_mod_push/test_space/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_kcl_mod_push/test_space/main.k create mode 100644 test/e2e/test_suites/test_kcl_mod_push_0/input create mode 100644 test/e2e/test_suites/test_kcl_mod_push_0/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_push_0/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_push_0/test_space/kcl.mod create mode 100644 test/e2e/test_suites/test_kcl_mod_push_0/test_space/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_kcl_mod_push_0/test_space/main.k create mode 100644 test/e2e/test_suites/test_kcl_mod_update/input create mode 100644 test/e2e/test_suites/test_kcl_mod_update/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_update/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_update/test_space/kcl.mod create mode 100644 test/e2e/test_suites/test_kcl_mod_update/test_space/main.k create mode 100644 test/e2e/test_suites/test_kcl_mod_update_0/input create mode 100644 test/e2e/test_suites/test_kcl_mod_update_0/stderr create mode 100644 test/e2e/test_suites/test_kcl_mod_update_0/stdout create mode 100644 test/e2e/test_suites/test_kcl_mod_update_0/test_space/pkg/kcl.mod create mode 100644 test/e2e/test_suites/test_kcl_mod_update_0/test_space/pkg/main.k create mode 100644 test/e2e/test_suites/test_kcl_run/input create mode 100644 test/e2e/test_suites/test_kcl_run/stderr create mode 100644 test/e2e/test_suites/test_kcl_run/stdout create mode 100644 test/e2e/test_suites/test_kcl_run/test_space/main.k create mode 100644 test/e2e/test_suites/test_kcl_run_0/input create mode 100644 test/e2e/test_suites/test_kcl_run_0/stderr create mode 100644 test/e2e/test_suites/test_kcl_run_0/stdout create mode 100644 test/e2e/test_suites/test_kcl_run_0/test_space/main.k create mode 100644 test/e2e/test_suites/test_kcl_run_1/input create mode 100644 test/e2e/test_suites/test_kcl_run_1/stderr create mode 100644 test/e2e/test_suites/test_kcl_run_1/stdout create mode 100644 test/e2e/test_suites/test_kcl_run_1/test_space/run.k create mode 100644 test/e2e/test_suites/test_kcl_run_1/test_space/run1.k create mode 100644 test/e2e/test_suites/test_kcl_run_2/input create mode 100644 test/e2e/test_suites/test_kcl_run_2/stderr create mode 100644 test/e2e/test_suites/test_kcl_run_2/stdout create mode 100644 test/e2e/test_suites/test_kcl_run_3/input create mode 100644 test/e2e/test_suites/test_kcl_run_3/stderr create mode 100644 test/e2e/test_suites/test_kcl_run_3/stdout create mode 100644 test/e2e/test_suites/test_kcl_run_3/test_space/kcl.mod create mode 100644 test/e2e/test_suites/test_kcl_run_3/test_space/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_kcl_run_3/test_space/main.k create mode 100644 test/e2e/utils.go diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml new file mode 100644 index 0000000..65f9923 --- /dev/null +++ b/.github/workflows/e2e-test.yml @@ -0,0 +1,20 @@ +name: e2e test +on: [push, pull_request] + +jobs: + e2e: + name: e2e test + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: install Go + uses: actions/setup-go@v2 + with: + go-version: 1.21 + + - name: run e2e + run: | + make e2e diff --git a/cmd/kcl/commands/mod_init.go b/cmd/kcl/commands/mod_init.go index c9dfb49..aadd570 100644 --- a/cmd/kcl/commands/mod_init.go +++ b/cmd/kcl/commands/mod_init.go @@ -35,7 +35,7 @@ func NewModInitCmd(cli *client.KpmClient) *cobra.Command { pwd, err := os.Getwd() if err != nil { - reporter.Fatal("kpm: internal bugs, please contact us to fix it") + reporter.Fatal("internal bugs, please contact us to fix it") } var pkgName string @@ -83,7 +83,7 @@ func NewModInitCmd(cli *client.KpmClient) *cobra.Command { return err } - reporter.ReportMsgTo(fmt.Sprintf("kpm: package '%s' init finished", pkgName), cli.GetLogWriter()) + reporter.ReportMsgTo(fmt.Sprintf("package '%s' init finished", pkgName), cli.GetLogWriter()) return nil }, SilenceUsage: true, diff --git a/cmd/kcl/commands/mod_pkg.go b/cmd/kcl/commands/mod_pkg.go index 754f402..7a328c2 100644 --- a/cmd/kcl/commands/mod_pkg.go +++ b/cmd/kcl/commands/mod_pkg.go @@ -45,13 +45,13 @@ func NewModPkgCmd(cli *client.KpmClient) *cobra.Command { pwd, err := os.Getwd() if err != nil { - reporter.ExitWithReport("kpm: internal bug: failed to load working directory") + reporter.ExitWithReport("internal bug: failed to load working directory") } kclPkg, err := pkg.LoadKclPkg(pwd) if err != nil { - reporter.ExitWithReport("kpm: failed to load package in " + pwd + ".") + reporter.ExitWithReport("failed to load package in " + pwd + ".") return err } diff --git a/cmd/kcl/commands/mod_push.go b/cmd/kcl/commands/mod_push.go index e969787..3ed2aa8 100644 --- a/cmd/kcl/commands/mod_push.go +++ b/cmd/kcl/commands/mod_push.go @@ -174,7 +174,7 @@ func pushPackage(ociUrl string, kclPkg *pkg.KclPkg, vendorMode bool, cli *client return err } - reporter.ReportMsgTo(fmt.Sprintf("kpm: package '%s' will be pushed", kclPkg.GetPkgName()), cli.GetLogWriter()) + reporter.ReportMsgTo(fmt.Sprintf("package '%s' will be pushed", kclPkg.GetPkgName()), cli.GetLogWriter()) // 4. Push it. err = cli.PushToOci(tarPath, ociOpts) if err != (*reporter.KpmEvent)(nil) { diff --git a/docs/dev-guide-e2e.md b/docs/dev-guide-e2e.md new file mode 100644 index 0000000..ef29ba5 --- /dev/null +++ b/docs/dev-guide-e2e.md @@ -0,0 +1,136 @@ + +# Add e2e test + +## 1. Quick Start +We have prepared the `e2e-init` command to help you initialize an empty e2e test case. The command format is as follows: + +``` +make e2e-init TS= +``` + +`` is the name of the test case. + +For example, to add a test case named `test_kcl_mod_init_1` to test the output of the `kcl mod init` command in a KCL package directory, you can use the following command: + +### 1.1. Create an empty test case +``` +make e2e-init TS=test_kcl_mod_init +``` + +You will get the following result: + +``` +Test suite created successfully in ./test/e2e/test_suites/test_kcl_mod_init_1. +``` +By this command, we can see that a new test case `test_kcl_mod_init_1` has been created in the `test/e2e/test_suites` directory of the project. + +``` +$ tree test/e2e/test_suites/test_kcl_mod_init_1 +test_kcl_mod_init_1 +├── input # The input of the test case +├── stderr # The expected output in stderr +├── stdout # The expected output in stdout +└── test_space # The test space is a empty directory and the `input` will run in this directory +``` + +### 1.2. Add the test environment to the `test_space` directory. + +For `test_kcl_mod_init_1`, we need to create a KCL package directory in the `test_space` directory. The directory structure is as follows: + +``` +$tree test/e2e/test_suites/test_kcl_mod_init_1/test_space +test_space +├── kcl.mod +├── kcl.mod.lock +└── main.k +``` + +### 1.3. Add the command to be tested to the `input` file. + +The content of the `input` file is as follows: + +``` +kcl mod init +``` + +### 1.4. The expected output + +`stderr` is empty, and the content in `stdout` is as follows: + +``` +creating new :/test_space/kcl.mod +'/test_space/kcl.mod' already exists +creating new :/test_space/kcl.mod.lock +'/test_space/kcl.mod.lock' already exists +creating new :/main.k +'/main.k' already exists +package 'test_space' init finished +``` + +In the content of the `stdout` file, `` is a variable that will be replaced with the absolute path of the `test_space` in the test process. + +### 1.5. Start test + +After completing these steps, run `make e2e` to start the test process. + +The test results will be displayed as follows: + +``` +Ran 3 of 3 Specs in 0.102 seconds +SUCCESS! -- 3 Passed | 0 Failed | 0 Pending | 0 Skipped +``` + +## 2. Adjust the execution path of the tested command + +By default, the command in the `input` file is executed in the `test_space` directory. However, in some more complex cases, we may want to execute the command in a subdirectory of `test_space`. We can use the `conf.json` file to specify the directory in which the command is executed. + +Take `test_kcl_mod_add_local` as an example to show the process. In this test case, we want to test the process of adding a KCL package in the local directory as a third-party dependency through the `kcl mod add` command. + +### 2.1. Use `e2e-init` to create a test case + +``` +make e2e-init TS=test_kcl_mod_add_local +``` + +### 2.2. Prepare the test environment + +In the `test_space` directory, prepare two KCL packages. The `pkg` package will add the `dep` package as a dependency through the `kcl mod add` command. + +``` +test_space +├── dep + │ ├── kcl.mod + │ ├── kcl.mod.lock + │ └── main.k +└── pkg + ├── kcl.mod + ├── kcl.mod.lock + └── main.k +``` + +### 2.3. Configure the execution directory + +Add a `conf.json` file to the `test_kcl_mod_add_local` directory to specify the execution directory of the command. + +``` +{ + "cwd": “test_space/pkg" +} +``` + +### 2.4. Add the command to be tested to the `input` file + +The content of the `input` file is as follows: + +``` +kcl mod add /dep +``` + +### 2.5. Add the expected output + +Add the expected output to the `stdout` file. + +``` + adding dependency 'dep' + add dependency 'dep:0.0.1' successfully +``` \ No newline at end of file diff --git a/go.mod b/go.mod index c7f63a3..fd92f03 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,8 @@ go 1.21 require ( github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d + github.com/onsi/ginkgo/v2 v2.11.0 + github.com/onsi/gomega v1.27.10 github.com/spf13/cobra v1.8.0 kcl-lang.io/kcl-go v0.8.0-beta.1 kcl-lang.io/kcl-openapi v0.5.5 @@ -11,7 +13,19 @@ require ( kcl-lang.io/kpm v0.8.0-beta.1 ) -require google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect +require ( + github.com/bytedance/sonic v1.9.1 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect + github.com/gabriel-vasile/mimetype v1.4.2 // indirect + github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect + github.com/goccy/go-json v0.10.2 // indirect + github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect + github.com/klauspost/cpuid/v2 v2.2.4 // indirect + github.com/pelletier/go-toml/v2 v2.0.8 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + golang.org/x/arch v0.3.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect +) require ( dario.cat/mergo v1.0.0 // indirect @@ -40,10 +54,10 @@ require ( github.com/docker/go-units v0.5.0 // indirect github.com/dominikbraun/graph v0.23.0 github.com/emirpasic/gods v1.18.1 // indirect - github.com/fatih/color v1.10.0 // indirect + github.com/fatih/color v1.10.0 github.com/getkin/kin-openapi v0.123.0 // indirect github.com/gin-contrib/sse v0.1.0 // indirect - github.com/gin-gonic/gin v1.7.7 // indirect + github.com/gin-gonic/gin v1.9.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect github.com/go-git/go-git/v5 v5.11.0 // indirect @@ -59,9 +73,9 @@ require ( github.com/go-openapi/strfmt v0.21.2 // indirect github.com/go-openapi/swag v0.22.8 // indirect github.com/go-openapi/validate v0.21.0 // indirect - github.com/go-playground/locales v0.13.0 // indirect - github.com/go-playground/universal-translator v0.17.0 // indirect - github.com/go-playground/validator/v10 v10.4.1 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.14.0 // indirect github.com/go-stack/stack v1.8.1 // indirect github.com/goccy/go-yaml v1.11.3 // indirect github.com/gofrs/flock v0.8.1 // indirect @@ -86,10 +100,10 @@ require ( github.com/klauspost/compress v1.16.0 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect - github.com/leodido/go-urn v1.2.0 // indirect + github.com/leodido/go-urn v1.2.4 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.8 // indirect - github.com/mattn/go-isatty v0.0.12 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/moby/locker v1.0.1 // indirect @@ -101,7 +115,7 @@ require ( github.com/oklog/ulid v1.3.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc4 // indirect - github.com/otiai10/copy v1.9.0 // indirect + github.com/otiai10/copy v1.9.0 github.com/perimeterx/marshmallow v1.1.5 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pkg/errors v0.9.1 @@ -116,8 +130,8 @@ require ( github.com/sirupsen/logrus v1.9.0 // indirect github.com/skeema/knownhosts v1.2.1 // indirect github.com/spf13/pflag v1.0.5 - github.com/thoas/go-funk v0.9.3 // indirect - github.com/ugorji/go/codec v1.2.7 // indirect + github.com/thoas/go-funk v0.9.3 + github.com/ugorji/go/codec v1.2.11 // indirect github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/yuin/goldmark v1.7.0 // indirect diff --git a/go.sum b/go.sum index 1ec24a7..691fd6f 100644 --- a/go.sum +++ b/go.sum @@ -113,6 +113,9 @@ github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0Bsq github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXer/kZD8Ri1aaunCxIEsOst1BVJswV0o= github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= +github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= +github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= +github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= @@ -125,6 +128,9 @@ github.com/chai2010/jsonv v1.1.3 h1:gBIHXn/5mdEPTuWZfjC54fn/yUSRR8OGobXobcc6now= github.com/chai2010/jsonv v1.1.3/go.mod h1:mEoT1dQ9qVF4oP9peVTl0UymTmJwXoTDOh+sNA6+XII= github.com/chai2010/protorpc v1.1.4 h1:CTtFUhzXRoeuR7FtgQ2b2vdT/KgWVpCM+sIus8zJjHs= github.com/chai2010/protorpc v1.1.4/go.mod h1:/wO0kiyVdu7ug8dCMrA2yDr2vLfyhsLEuzLa9J2HJ+I= +github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -215,6 +221,8 @@ github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoD github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= +github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/getkin/kin-openapi v0.76.0/go.mod h1:660oXbgy5JFMKreazJaQTw7o+X00qeSyhcnluiMv+Xg= github.com/getkin/kin-openapi v0.123.0 h1:zIik0mRwFNLyvtXK274Q6ut+dPh6nlxBp0x7mNrPhs8= github.com/getkin/kin-openapi v0.123.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM= @@ -222,8 +230,8 @@ github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49P github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs= -github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U= +github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= +github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= @@ -291,17 +299,19 @@ github.com/go-openapi/swag v0.22.8 h1:/9RjDSQ0vbFR+NyjGMkFTsA1IA0fmhKSThmfGZjicb github.com/go-openapi/swag v0.22.8/go.mod h1:6QT22icPLEqAM/z/TChgb4WAveCHF92+2gF0CNjHpPI= github.com/go-openapi/validate v0.21.0 h1:+Wqk39yKOhfpLqNLEC0/eViCkzM5FVXVqrvt526+wcI= github.com/go-openapi/validate v0.21.0/go.mod h1:rjnrwK57VJ7A8xqfpAOEKRH8yQSGUriMu5/zuPSQ1hg= -github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= -github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= +github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= @@ -328,6 +338,8 @@ github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWe github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= +github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-yaml v1.11.3 h1:B3W9IdWbvrUu2OYQGwvU1nZtvMQJPBKgBUuweJjLj6I= github.com/goccy/go-yaml v1.11.3/go.mod h1:wKnAMd44+9JAAnGQpWVEgBzGt3YuTaQ4uXoHvE4m7WU= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -421,6 +433,8 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y= +github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -470,6 +484,7 @@ github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSAS github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= @@ -486,7 +501,6 @@ github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFF github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -508,6 +522,9 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= +github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -522,8 +539,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= +github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -536,8 +553,9 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= @@ -588,6 +606,8 @@ github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= +github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= @@ -608,6 +628,8 @@ github.com/otiai10/mint v1.4.0/go.mod h1:gifjb2MYOoULtKLqUAEILUG/9KONW6f7YsJ6vQL github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= +github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= +github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s= github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= @@ -723,6 +745,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= @@ -732,11 +756,10 @@ github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= -github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= -github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= @@ -810,6 +833,9 @@ go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9i go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= +golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -1021,11 +1047,13 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1340,6 +1368,7 @@ oras.land/oras-go v1.2.3/go.mod h1:M/uaPdYklze0Vf3AakfarnpoEckvw0ESbRdN8Z1vdJg= oras.land/oras-go/v2 v2.3.0 h1:lqX1aXdN+DAmDTKjiDyvq85cIaI4RkIKp/PghWlAGIU= oras.land/oras-go/v2 v2.3.0/go.mod h1:GeAwLuC4G/JpNwkd+bSZ6SkDMGaaYglt6YK2WvZP7uQ= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.30/go.mod h1:fEO7lRTdivWO2qYVCVG7dEADOMo/MLDCVr8So2g88Uw= diff --git a/makefile b/makefile index a7aef4e..451cd6a 100644 --- a/makefile +++ b/makefile @@ -82,3 +82,11 @@ release: lint dist .PHONY: tag tag: scripts/tag.sh v$(VERSION) + +.PHONY: e2e +e2e: ## Run e2e test + scripts/e2e/e2e.sh + +.PHONY: e2e-init +e2e-init: + scripts/e2e/e2e-init.sh $(TS) diff --git a/pkg/options/import.go b/pkg/options/import.go index 5857e25..7e49fc1 100644 --- a/pkg/options/import.go +++ b/pkg/options/import.go @@ -92,7 +92,7 @@ func (o *ImportOptions) Run() error { } return nil default: - return fmt.Errorf("kpm: invalid mode: %s", o.Mode) + return fmt.Errorf("invalid mode: %s", o.Mode) } if o.Output == "-" { diff --git a/scripts/e2e/e2e-init.sh b/scripts/e2e/e2e-init.sh new file mode 100755 index 0000000..efcc253 --- /dev/null +++ b/scripts/e2e/e2e-init.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Check if a directory name is provided +if [ "$#" -ne 1 ]; then + echo "Usage: " + exit 1 +fi + +# Specify the directory +dir="./test/e2e/test_suites/$1" + +# Create the subdirectory if it does not exist +if [ ! -d "$dir" ]; then + mkdir -p "$dir" +fi + +# Create files in the directory + +touch "${dir}/input" +echo "stdout" > "${dir}/stdout" +echo "stderr" > "${dir}/stderr" +mkdir -p "${dir}/test_space" + + +echo "Test suite created successfully in $dir." \ No newline at end of file diff --git a/scripts/e2e/e2e.sh b/scripts/e2e/e2e.sh new file mode 100755 index 0000000..5712159 --- /dev/null +++ b/scripts/e2e/e2e.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# start registry at 'localhost:5001' +# include account 'test' and password '1234' +./scripts/e2e/reg.sh + +# set the kpm default registry and repository +export KPM_REG="localhost:5001" +export KPM_REPO="test" +export OCI_REG_PLAIN_HTTP=on + +set -o errexit +set -o nounset +set -o pipefail + +# Install ginkgo +GO111MODULE=on go install github.com/onsi/ginkgo/v2/ginkgo@v2.0.0 + +# Build kpm binary +make build + +# Prepare e2e test env +# pull the package 'k8s' from 'ghcr.io/kcl-lang/k8s' +./scripts/e2e/pull_pkg.sh + +# push the package 'k8s' to 'localhost:5001/test' +./scripts/e2e/push_pkg.sh + +# Run e2e +set +e +ginkgo ./test/e2e/ +TESTING_RESULT=$? + + +exit $TESTING_RESULT diff --git a/scripts/e2e/pkg_in_reg/kcl1/kcl.mod b/scripts/e2e/pkg_in_reg/kcl1/kcl.mod new file mode 100644 index 0000000..d94b360 --- /dev/null +++ b/scripts/e2e/pkg_in_reg/kcl1/kcl.mod @@ -0,0 +1,7 @@ +[package] +name = "kcl1" +edition = "v0.7.0" +version = "0.0.1" + +[dependencies] +helloworld = "0.1.1" diff --git a/scripts/e2e/pkg_in_reg/kcl1/kcl.mod.lock b/scripts/e2e/pkg_in_reg/kcl1/kcl.mod.lock new file mode 100644 index 0000000..aee4146 --- /dev/null +++ b/scripts/e2e/pkg_in_reg/kcl1/kcl.mod.lock @@ -0,0 +1,9 @@ +[dependencies] + [dependencies.helloworld] + name = "helloworld" + full_name = "helloworld_0.1.1" + version = "0.1.1" + sum = "7OO4YK2QuRWPq9C7KTzcWcti5yUnueCjptT3OXiPVeQ=" + reg = "localhost:5001" + repo = "test/helloworld" + oci_tag = "0.1.1" diff --git a/scripts/e2e/pkg_in_reg/kcl1/main.k b/scripts/e2e/pkg_in_reg/kcl1/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/scripts/e2e/pkg_in_reg/kcl1/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/scripts/e2e/pkg_in_reg/kcl2/kcl.mod b/scripts/e2e/pkg_in_reg/kcl2/kcl.mod new file mode 100644 index 0000000..18c3740 --- /dev/null +++ b/scripts/e2e/pkg_in_reg/kcl2/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "kcl2" +edition = "v0.7.0" +version = "0.0.1" + diff --git a/scripts/e2e/pkg_in_reg/kcl2/kcl.mod.lock b/scripts/e2e/pkg_in_reg/kcl2/kcl.mod.lock new file mode 100644 index 0000000..e69de29 diff --git a/scripts/e2e/pkg_in_reg/kcl2/main.k b/scripts/e2e/pkg_in_reg/kcl2/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/scripts/e2e/pkg_in_reg/kcl2/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/scripts/e2e/pull_pkg.sh b/scripts/e2e/pull_pkg.sh new file mode 100755 index 0000000..1ab08ca --- /dev/null +++ b/scripts/e2e/pull_pkg.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# set the kpm default registry and repository +export KPM_REG="ghcr.io" +export KPM_REPO="kcl-lang" +export OCI_REG_PLAIN_HTTP=off + +current_dir=$(pwd) + +mkdir -p ./scripts/e2e/pkg_in_reg/ + +cd ./scripts/e2e/pkg_in_reg/ + + +# Check if file exists +if [ ! -d "./ghcr.io/kcl-lang/k8s/1.28" ]; then + $current_dir/bin/kcl mod pull k8s:1.28 +fi + +if [ ! -d "./ghcr.io/kcl-lang/helloworld" ]; then + $current_dir/bin/kcl mod pull helloworld +fi + +cd "$current_dir" diff --git a/scripts/e2e/push_pkg.sh b/scripts/e2e/push_pkg.sh new file mode 100755 index 0000000..205ad2b --- /dev/null +++ b/scripts/e2e/push_pkg.sh @@ -0,0 +1,33 @@ + +#!/usr/bin/env bash + +export KPM_REG="localhost:5001" +export KPM_REPO="test" +export OCI_REG_PLAIN_HTTP=on + +# Prepare the package on the registry +current_dir=$(pwd) +echo $current_dir + +$current_dir/bin/kcl registry login -u test -p 1234 localhost:5001 + +cd ./scripts/e2e/pkg_in_reg/ghcr.io/kcl-lang/k8s/1.28 +$current_dir/bin/kcl mod push + +cd "$current_dir" + +# Push the package k8s/1.17 to the registry +cd ./scripts/e2e/pkg_in_reg/ghcr.io/kcl-lang/helloworld +$current_dir/bin/kcl mod push + +cd "$current_dir" + +# Push the package 'kcl1' depends on 'k8s' to the registry +cd ./scripts/e2e/pkg_in_reg/kcl1 +$current_dir/bin/kcl mod push + +cd "$current_dir" + +# Push the package 'kcl2' depends on 'k8s' to the registry +cd ./scripts/e2e/pkg_in_reg/kcl2 +$current_dir/bin/kcl mod push diff --git a/scripts/e2e/reg.sh b/scripts/e2e/reg.sh new file mode 100755 index 0000000..4ef4124 --- /dev/null +++ b/scripts/e2e/reg.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# create a directory to store user passwords +mkdir -p ./scripts/e2e/registry_auth + +# use htpasswd to create an encrypted file +htpasswd -Bbn test 1234 > ./scripts/e2e/registry_auth/htpasswd + +# check if there is a container named registry +if [ "$(docker ps -aq -f name=registry)" ]; then + # stop and remove the container named registry + docker stop registry + docker rm registry +fi + +# start the Docker Registry with authentication +docker run -p 5001:5000 \ +--restart=always \ +--name registry \ +-v /var/lib/registry:/var/lib/registry \ +-v $PWD/scripts/e2e/registry_auth/:/auth/ \ +-e "REGISTRY_AUTH=htpasswd" \ +-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \ +-e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd" \ +-d registry + +# clean the registry +docker exec registry rm -rf /var/lib/registry/docker/registry/v2/repositories/ diff --git a/scripts/e2e/registry_auth/htpasswd b/scripts/e2e/registry_auth/htpasswd new file mode 100644 index 0000000..9dc5993 --- /dev/null +++ b/scripts/e2e/registry_auth/htpasswd @@ -0,0 +1,2 @@ +test:$2y$05$qpdE2KgdrnW4Ky5MtPlsJuYwWhHJXS4LoWgc8.JCipTgCyZCB.eHa + diff --git a/test/e2e/cli.go b/test/e2e/cli.go new file mode 100644 index 0000000..37fd657 --- /dev/null +++ b/test/e2e/cli.go @@ -0,0 +1,155 @@ +package e2e + +import ( + "io" + "os" + "os/exec" + "path/filepath" + "strings" + "time" + + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega/gexec" + "kcl-lang.io/kpm/pkg/reporter" +) + +const TEST_WORKSPACE = "test_kpm_workspace" + +// CreateTestWorkspace create an empty dir "($pwd)/test_kpm_workspace" for test kpm cli. +func CreateTestWorkspace() string { + workspacePath := filepath.Join(GetWorkDir(), TEST_WORKSPACE) + err := os.MkdirAll(workspacePath, 0755) + if err != nil { + reporter.ExitWithReport("failed to create workspace.") + } + return workspacePath +} + +// CleanUpTestWorkspace will do 'rm -rf' to the "($pwd)/test_kpm_workspace". +func CleanUpTestWorkspace() string { + workspacePath := filepath.Join(GetWorkDir(), TEST_WORKSPACE) + err := os.RemoveAll(workspacePath) + if err != nil { + reporter.ExitWithReport("failed to clean up workspace.") + } + return workspacePath +} + +// GetWorkspace return the path of test workspace. +func GetWorkspace() string { + return filepath.Join(GetWorkDir(), TEST_WORKSPACE) +} + +// GetWrokDir return work directory +func GetWorkDir() string { + dir, err := os.Getwd() + if err != nil { + reporter.ExitWithReport("failed to load workspace.") + } + return dir +} + +// GetKpmCLIBin return kusion binary path in e2e test +func GetKpmCLIBin() string { + dir, _ := os.Getwd() + binPath := filepath.Join(dir, "../..", "bin") + return binPath +} + +// Exec execute common command +func Exec(cli string) (string, string, error) { + var output []byte + c := strings.Fields(cli) + command := exec.Command(c[0], c[1:]...) + session, err := gexec.Start(command, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter) + if err != nil { + return string(output), string(output), err + } + s := session.Wait(300 * time.Second) + return string(s.Out.Contents()), string(s.Err.Contents()), nil +} + +// Exec execute common command +func ExecWithWorkDir(cli, dir string) (string, error) { + var output []byte + c := strings.Fields(cli) + command := exec.Command(c[0], c[1:]...) + command.Dir = dir + session, err := gexec.Start(command, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter) + if err != nil { + return string(output), err + } + s := session.Wait(300 * time.Second) + return string(s.Out.Contents()) + string(s.Err.Contents()), nil +} + +// ExecKpm executes kusion command +func ExecKpm(cli string) (string, error) { + var output []byte + c := strings.Fields(cli) + commandName := filepath.Join(GetKpmCLIBin(), c[0]) + command := exec.Command(commandName, c[1:]...) + session, err := gexec.Start(command, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter) + if err != nil { + return string(output), err + } + s := session.Wait(300 * time.Second) + return string(s.Out.Contents()) + string(s.Err.Contents()), nil +} + +// ExecKpmWithInDirWithEnv executes kpm command in work directory with env. +func ExecKpmWithInDirWithEnv(cli, dir, env string) (string, string, error) { + var output []byte + c := strings.Fields(cli) + commandName := filepath.Join(GetKpmCLIBin(), c[0]) + command := exec.Command(commandName, c[1:]...) + command.Dir = dir + + // Set the env + envLines := strings.FieldsFunc(env, func(c rune) bool { return c == '\n' }) + command.Env = append(command.Env, envLines...) + session, err := gexec.Start(command, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter) + if err != nil { + return string(output), string(output), err + } + s := session.Wait(300 * time.Second) + return string(s.Out.Contents()), string(s.Err.Contents()), nil +} + +// ExecKpmWithWorkDir executes kpm command in work directory +func ExecKpmWithWorkDir(cli, dir string) (string, string, error) { + var output []byte + c := SplitCommand(cli) + commandName := filepath.Join(GetKpmCLIBin(), c[0]) + command := exec.Command(commandName, c[1:]...) + command.Dir = dir + session, err := gexec.Start(command, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter) + if err != nil { + return string(output), string(output), err + } + s := session.Wait(300 * time.Second) + return string(s.Out.Contents()), string(s.Err.Contents()), nil +} + +// ExecKpmWithStdin executes kpm command in work directory with stdin +func ExecKpmWithStdin(cli, dir, input string) (string, error) { + var output []byte + c := strings.Fields(cli) + commandName := filepath.Join(GetKpmCLIBin(), c[0]) + command := exec.Command(commandName, c[1:]...) + command.Dir = dir + subStdin, err := command.StdinPipe() + if err != nil { + return string(output), err + } + _, err = io.WriteString(subStdin, input) + if err != nil { + return string(output), err + } + session, err := gexec.Start(command, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter) + if err != nil { + return string(output), err + } + s := session.Wait(300 * time.Second) + return string(s.Out.Contents()) + string(s.Err.Contents()), nil +} diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go new file mode 100644 index 0000000..0667cd6 --- /dev/null +++ b/test/e2e/e2e_suite_test.go @@ -0,0 +1,38 @@ +package e2e + +import ( + "fmt" + "path/filepath" + "testing" + + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" +) + +func TestE2e(t *testing.T) { + gomega.RegisterFailHandler(ginkgo.Fail) + ginkgo.RunSpecs(t, "E2e Suite") +} + +var _ = ginkgo.BeforeEach(func() { + ginkgo.By("create kpm test workspace", func() { + _ = CreateTestWorkspace() + }) +}) + +var _ = ginkgo.AfterEach(func() { + ginkgo.By("clean up kpm test workspace", func() { + _ = CleanUpTestWorkspace() + }) +}) + +var _ = ginkgo.AfterSuite(func() { + ginkgo.By("clean up kpm bin", func() { + path := filepath.Join(GetWorkDir(), "../..", "bin") + cli := fmt.Sprintf("rm -rf %s", path) + stdout, stderr, err := Exec(cli) + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) + gomega.Expect(stdout).To(gomega.BeEmpty()) + gomega.Expect(stderr).To(gomega.BeEmpty()) + }) +}) diff --git a/test/e2e/kpm_test.go b/test/e2e/kpm_test.go new file mode 100644 index 0000000..43dfa08 --- /dev/null +++ b/test/e2e/kpm_test.go @@ -0,0 +1,69 @@ +package e2e + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/fatih/color" + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" + "github.com/otiai10/copy" + "kcl-lang.io/kpm/pkg/utils" +) + +var _ = ginkgo.Describe("Kpm CLI Testing", func() { + ginkgo.Context("testing...", func() { + testSuitesHome := filepath.Join(GetWorkDir(), TEST_SUITES_DIR) + testSuites := LoadAllTestSuites(testSuitesHome) + + for _, ts := range testSuites { + // In the for loop, the variable ts is defined outside the scope of the ginkgo.It function. + // This means that when the ginkgo.It function is executed, + // it will always use the value of ts from the last iteration of the for loop. + // To fix this issue, create a new variable inside the loop with the same value as ts, + // and use that variable inside the ginkgo.It function. + ts := ts + ginkgo.Describe(ts.GetTestSuiteInfo(), func() { + testSpace := filepath.Join(testSuitesHome, ts.Name, "test_space") + tmp := filepath.Join(testSuitesHome, ts.Name, "tmp") + ginkgo.BeforeEach(func() { + if !utils.DirExists(testSpace) { + err := os.MkdirAll(testSpace, 0755) + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) + } + // backup the test space + err := copy.Copy(testSpace, tmp) + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) + }) + + ginkgo.AfterEach(func() { + // restore the test space + err := os.RemoveAll(testSpace) + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) + err = copy.Copy(tmp, testSpace) + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) + err = os.RemoveAll(tmp) + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) + }) + + ginkgo.It(ts.GetTestSuiteInfo(), func() { + if ts.ignore || ts.Input == "" { + fmt.Printf("skipped: %s\n", ts.Name) + ginkgo.Skip(ts.Name) + } + stdout, stderr, err := ExecKpmWithWorkDir(ts.Input, ts.Conf.Cwd) + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) + if stdout == ts.ExpectStdout && stderr == ts.ExpectStderr { + gomega.Expect(ts.ExpectStdout).Should(gomega.Equal(stdout)) + gomega.Expect(ts.ExpectStderr).Should(gomega.Equal(stderr)) + } else { + fmt.Printf("\n%s : check expected output contains: %s", color.YellowString("[warning]"), ts.Name) + gomega.Expect(stdout).Should(gomega.ContainSubstring(ts.ExpectStdout)) + gomega.Expect(stderr).Should(gomega.ContainSubstring(ts.ExpectStderr)) + } + }) + }) + } + }) +}) diff --git a/test/e2e/test_suite.go b/test/e2e/test_suite.go new file mode 100644 index 0000000..fc623e6 --- /dev/null +++ b/test/e2e/test_suite.go @@ -0,0 +1,113 @@ +package e2e + +import ( + "fmt" + "log" + "os" + "path/filepath" + "strings" + + "encoding/json" + + "kcl-lang.io/kpm/pkg/reporter" + "kcl-lang.io/kpm/pkg/utils" +) + +const TEST_SUITES_DIR = "test_suites" + +const ENV = "env" +const CONF = "conf.json" +const STDOUT = "stdout" +const STDERR = "stderr" +const INPUT = "input" +const IGNORE = "ignore" + +type TestConf struct { + Cwd string +} + +type TestSuite struct { + Name string + Envs string + Input string + ExpectStdout string + ExpectStderr string + ignore bool + Conf TestConf +} + +// LoadTestSuite load test suite from 'getWorkDir()/test_suites/name'. +func LoadTestSuite(testSuitePath, name string) *TestSuite { + reporter.Report("testing: ", name) + + confPath := filepath.Join(testSuitePath, CONF) + var conf TestConf + + if utils.DirExists(confPath) { + err := json.Unmarshal([]byte(LoadFile(confPath)), &conf) + if err != nil { + log.Fatal(err) + } + } + + if conf.Cwd == "" { + conf.Cwd = filepath.Join(testSuitePath, "test_space") + } else { + conf.Cwd = filepath.Join(testSuitePath, conf.Cwd) + } + + ts := TestSuite{ + Name: name, + ExpectStdout: LoadFile(filepath.Join(testSuitePath, STDOUT)), + ExpectStderr: LoadFile(filepath.Join(testSuitePath, STDERR)), + Input: LoadFile(filepath.Join(testSuitePath, INPUT)), + // Envs: LoadFile(filepath.Join(testSuitePath, ENV)), + ignore: utils.DirExists(filepath.Join(testSuitePath, IGNORE)), + Conf: conf, + } + return ts.ReplaceStringVar(testSuitePath) +} + +func (ts *TestSuite) ReplaceStringVar(testSuitePath string) *TestSuite { + ts.ExpectStdout = strings.ReplaceAll(ts.ExpectStdout, "", testSuitePath) + ts.ExpectStderr = strings.ReplaceAll(ts.ExpectStderr, "", testSuitePath) + ts.Input = strings.ReplaceAll(ts.Input, "", testSuitePath) + return ts +} + +// LoadFile will read the file from 'path' and return the content. +func LoadFile(path string) string { + content, err := os.ReadFile(path) + if err != nil { + log.Fatal(err) + } + + return string(content) +} + +// LoadAllTestSuites load all test suites from 'getWorkDir()/test_suites'. +func LoadAllTestSuites(testSuitesDir string) []TestSuite { + testSuites := make([]TestSuite, 0) + files, err := os.ReadDir(testSuitesDir) + + if err != nil { + log.Fatal(err) + } + + for _, file := range files { + ts := LoadTestSuite(filepath.Join(testSuitesDir, file.Name()), file.Name()) + if file.IsDir() && ts != nil { + testSuites = append( + testSuites, + *ts, + ) + } + } + + return testSuites +} + +// GetTestSuiteInfo return a info for a test suite "::" +func (ts *TestSuite) GetTestSuiteInfo() string { + return fmt.Sprintf("%s:%s", ts.Name, strings.ReplaceAll(ts.Envs, "\n", ":")) +} diff --git a/test/e2e/test_suites/test_kcl_mod_add_git/input b/test/e2e/test_suites/test_kcl_mod_add_git/input new file mode 100644 index 0000000..99527eb --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_git/input @@ -0,0 +1 @@ +kcl mod add --git https://github.com/kcl-lang/konfig --tag v0.4.0 \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_add_git/stderr b/test/e2e/test_suites/test_kcl_mod_add_git/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_add_git/stdout b/test/e2e/test_suites/test_kcl_mod_add_git/stdout new file mode 100644 index 0000000..66c0de8 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_git/stdout @@ -0,0 +1,4 @@ +adding dependency 'konfig' +cloning 'https://github.com/kcl-lang/konfig' with tag 'v0.4.0' +downloading 'test/k8s:1.28' from 'localhost:5001/test/k8s:1.28' +add dependency 'konfig:v0.4.0' successfully diff --git a/test/e2e/test_suites/test_kcl_mod_add_git/test_space/kcl.mod b/test/e2e/test_suites/test_kcl_mod_add_git/test_space/kcl.mod new file mode 100644 index 0000000..0c2f8cd --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_git/test_space/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "test_space" +edition = "v0.7.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_kcl_mod_add_git/test_space/kcl.mod.lock b/test/e2e/test_suites/test_kcl_mod_add_git/test_space/kcl.mod.lock new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_add_git/test_space/main.k b/test/e2e/test_suites/test_kcl_mod_add_git/test_space/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_git/test_space/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_add_local/conf.json b/test/e2e/test_suites/test_kcl_mod_add_local/conf.json new file mode 100644 index 0000000..eff7fdd --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_local/conf.json @@ -0,0 +1,3 @@ +{ + "cwd": "test_space/pkg" +} \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_add_local/input b/test/e2e/test_suites/test_kcl_mod_add_local/input new file mode 100644 index 0000000..184bceb --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_local/input @@ -0,0 +1 @@ +kcl mod add /test_space/dep \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_add_local/stderr b/test/e2e/test_suites/test_kcl_mod_add_local/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_add_local/stdout b/test/e2e/test_suites/test_kcl_mod_add_local/stdout new file mode 100644 index 0000000..a030b6e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_local/stdout @@ -0,0 +1,2 @@ +adding dependency 'dep' +add dependency 'dep:0.0.1' successfully diff --git a/test/e2e/test_suites/test_kcl_mod_add_local/test_space/dep/kcl.mod b/test/e2e/test_suites/test_kcl_mod_add_local/test_space/dep/kcl.mod new file mode 100644 index 0000000..b196117 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_local/test_space/dep/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "dep" +edition = "v0.7.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_kcl_mod_add_local/test_space/dep/kcl.mod.lock b/test/e2e/test_suites/test_kcl_mod_add_local/test_space/dep/kcl.mod.lock new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_add_local/test_space/dep/main.k b/test/e2e/test_suites/test_kcl_mod_add_local/test_space/dep/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_local/test_space/dep/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_add_local/test_space/pkg/kcl.mod b/test/e2e/test_suites/test_kcl_mod_add_local/test_space/pkg/kcl.mod new file mode 100644 index 0000000..05d264c --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_local/test_space/pkg/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "pkg" +edition = "v0.8.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_kcl_mod_add_local/test_space/pkg/kcl.mod.lock b/test/e2e/test_suites/test_kcl_mod_add_local/test_space/pkg/kcl.mod.lock new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_add_local/test_space/pkg/main.k b/test/e2e/test_suites/test_kcl_mod_add_local/test_space/pkg/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_local/test_space/pkg/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_add_local_0/conf.json b/test/e2e/test_suites/test_kcl_mod_add_local_0/conf.json new file mode 100644 index 0000000..eff7fdd --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_local_0/conf.json @@ -0,0 +1,3 @@ +{ + "cwd": "test_space/pkg" +} \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_add_local_0/input b/test/e2e/test_suites/test_kcl_mod_add_local_0/input new file mode 100644 index 0000000..184bceb --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_local_0/input @@ -0,0 +1 @@ +kcl mod add /test_space/dep \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_add_local_0/stderr b/test/e2e/test_suites/test_kcl_mod_add_local_0/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_add_local_0/stdout b/test/e2e/test_suites/test_kcl_mod_add_local_0/stdout new file mode 100644 index 0000000..ff6291d --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_local_0/stdout @@ -0,0 +1,3 @@ +adding dependency 'dep' +downloading 'test/helloworld:0.1.1' from 'localhost:5001/test/helloworld:0.1.1' +add dependency 'dep:0.0.1' successfully diff --git a/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/dep/kcl.mod b/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/dep/kcl.mod new file mode 100644 index 0000000..6f61831 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/dep/kcl.mod @@ -0,0 +1,7 @@ +[package] +name = "dep" +edition = "v0.7.0" +version = "0.0.1" + +[dependencies] +helloworld = "0.1.1" diff --git a/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/dep/kcl.mod.lock b/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/dep/kcl.mod.lock new file mode 100644 index 0000000..aee4146 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/dep/kcl.mod.lock @@ -0,0 +1,9 @@ +[dependencies] + [dependencies.helloworld] + name = "helloworld" + full_name = "helloworld_0.1.1" + version = "0.1.1" + sum = "7OO4YK2QuRWPq9C7KTzcWcti5yUnueCjptT3OXiPVeQ=" + reg = "localhost:5001" + repo = "test/helloworld" + oci_tag = "0.1.1" diff --git a/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/dep/main.k b/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/dep/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/dep/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/pkg/kcl.mod b/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/pkg/kcl.mod new file mode 100644 index 0000000..9ba9a1e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/pkg/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "pkg" +edition = "v0.7.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/pkg/kcl.mod.lock b/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/pkg/kcl.mod.lock new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/pkg/main.k b/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/pkg/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_local_0/test_space/pkg/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci/input b/test/e2e/test_suites/test_kcl_mod_add_oci/input new file mode 100644 index 0000000..0f6f34d --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_oci/input @@ -0,0 +1 @@ +kcl mod add helloworld \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci/stderr b/test/e2e/test_suites/test_kcl_mod_add_oci/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci/stdout b/test/e2e/test_suites/test_kcl_mod_add_oci/stdout new file mode 100644 index 0000000..f0dbf71 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_oci/stdout @@ -0,0 +1,4 @@ +adding dependency 'helloworld' +the lastest version '0.1.1' will be added +downloading 'test/helloworld:0.1.1' from 'localhost:5001/test/helloworld:0.1.1' +add dependency 'helloworld' successfully diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci/test_space/kcl.mod b/test/e2e/test_suites/test_kcl_mod_add_oci/test_space/kcl.mod new file mode 100644 index 0000000..0c2f8cd --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_oci/test_space/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "test_space" +edition = "v0.7.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci/test_space/kcl.mod.lock b/test/e2e/test_suites/test_kcl_mod_add_oci/test_space/kcl.mod.lock new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci/test_space/main.k b/test/e2e/test_suites/test_kcl_mod_add_oci/test_space/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_oci/test_space/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci_0/input b/test/e2e/test_suites/test_kcl_mod_add_oci_0/input new file mode 100644 index 0000000..46cacd3 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_oci_0/input @@ -0,0 +1 @@ +kcl mod add helloworld:0.1.1 \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci_0/stderr b/test/e2e/test_suites/test_kcl_mod_add_oci_0/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci_0/stdout b/test/e2e/test_suites/test_kcl_mod_add_oci_0/stdout new file mode 100644 index 0000000..85458c2 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_oci_0/stdout @@ -0,0 +1,3 @@ +adding dependency 'helloworld' +downloading 'test/helloworld:0.1.1' from 'localhost:5001/test/helloworld:0.1.1' +add dependency 'helloworld:0.1.1' successfully diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci_0/test_space/kcl.mod b/test/e2e/test_suites/test_kcl_mod_add_oci_0/test_space/kcl.mod new file mode 100644 index 0000000..0c2f8cd --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_oci_0/test_space/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "test_space" +edition = "v0.7.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci_0/test_space/kcl.mod.lock b/test/e2e/test_suites/test_kcl_mod_add_oci_0/test_space/kcl.mod.lock new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci_0/test_space/main.k b/test/e2e/test_suites/test_kcl_mod_add_oci_0/test_space/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_oci_0/test_space/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci_1/input b/test/e2e/test_suites/test_kcl_mod_add_oci_1/input new file mode 100644 index 0000000..e11216b --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_oci_1/input @@ -0,0 +1 @@ +kcl mod add kcl1 \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci_1/stderr b/test/e2e/test_suites/test_kcl_mod_add_oci_1/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci_1/stdout b/test/e2e/test_suites/test_kcl_mod_add_oci_1/stdout new file mode 100644 index 0000000..3283f49 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_oci_1/stdout @@ -0,0 +1,5 @@ +adding dependency 'kcl1' +the lastest version '0.0.1' will be added +downloading 'test/kcl1:0.0.1' from 'localhost:5001/test/kcl1:0.0.1' +downloading 'test/helloworld:0.1.1' from 'localhost:5001/test/helloworld:0.1.1' +add dependency 'kcl1' successfully diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci_1/test_space/kcl.mod b/test/e2e/test_suites/test_kcl_mod_add_oci_1/test_space/kcl.mod new file mode 100644 index 0000000..0c2f8cd --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_oci_1/test_space/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "test_space" +edition = "v0.7.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci_1/test_space/kcl.mod.lock b/test/e2e/test_suites/test_kcl_mod_add_oci_1/test_space/kcl.mod.lock new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_add_oci_1/test_space/main.k b/test/e2e/test_suites/test_kcl_mod_add_oci_1/test_space/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_add_oci_1/test_space/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_init/input b/test/e2e/test_suites/test_kcl_mod_init/input new file mode 100644 index 0000000..a5c1300 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_init/input @@ -0,0 +1 @@ +kcl mod init \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_init/stderr b/test/e2e/test_suites/test_kcl_mod_init/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_init/stdout b/test/e2e/test_suites/test_kcl_mod_init/stdout new file mode 100644 index 0000000..d50e09a --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_init/stdout @@ -0,0 +1,4 @@ +creating new :/test_space/kcl.mod +creating new :/test_space/kcl.mod.lock +creating new :/test_space/main.k +package 'test_space' init finished diff --git a/test/e2e/test_suites/test_kcl_mod_init_0/input b/test/e2e/test_suites/test_kcl_mod_init_0/input new file mode 100644 index 0000000..a5c1300 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_init_0/input @@ -0,0 +1 @@ +kcl mod init \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_init_0/stderr b/test/e2e/test_suites/test_kcl_mod_init_0/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_init_0/stdout b/test/e2e/test_suites/test_kcl_mod_init_0/stdout new file mode 100644 index 0000000..8c96a2c --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_init_0/stdout @@ -0,0 +1,6 @@ +creating new :/test_space/kcl.mod +creating new :/test_space/kcl.mod.lock +'/test_space/kcl.mod.lock' already exists +creating new :/test_space/main.k +'/test_space/main.k' already exists +package 'test_space' init finished diff --git a/test/e2e/test_suites/test_kcl_mod_init_0/test_space/kcl.mod.lock b/test/e2e/test_suites/test_kcl_mod_init_0/test_space/kcl.mod.lock new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_init_0/test_space/main.k b/test/e2e/test_suites/test_kcl_mod_init_0/test_space/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_init_0/test_space/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_init_1/input b/test/e2e/test_suites/test_kcl_mod_init_1/input new file mode 100644 index 0000000..a5c1300 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_init_1/input @@ -0,0 +1 @@ +kcl mod init \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_init_1/stderr b/test/e2e/test_suites/test_kcl_mod_init_1/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_init_1/stdout b/test/e2e/test_suites/test_kcl_mod_init_1/stdout new file mode 100644 index 0000000..c3f558c --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_init_1/stdout @@ -0,0 +1,7 @@ +creating new :/test_space/kcl.mod +'/test_space/kcl.mod' already exists +creating new :/test_space/kcl.mod.lock +'/test_space/kcl.mod.lock' already exists +creating new :/test_space/main.k +'/test_space/main.k' already exists +package 'test_space' init finished diff --git a/test/e2e/test_suites/test_kcl_mod_init_1/test_space/kcl.mod b/test/e2e/test_suites/test_kcl_mod_init_1/test_space/kcl.mod new file mode 100644 index 0000000..0c2f8cd --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_init_1/test_space/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "test_space" +edition = "v0.7.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_kcl_mod_init_1/test_space/kcl.mod.lock b/test/e2e/test_suites/test_kcl_mod_init_1/test_space/kcl.mod.lock new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_init_1/test_space/main.k b/test/e2e/test_suites/test_kcl_mod_init_1/test_space/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_init_1/test_space/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_init_2/input b/test/e2e/test_suites/test_kcl_mod_init_2/input new file mode 100644 index 0000000..a5c1300 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_init_2/input @@ -0,0 +1 @@ +kcl mod init \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_init_2/stderr b/test/e2e/test_suites/test_kcl_mod_init_2/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_init_2/stdout b/test/e2e/test_suites/test_kcl_mod_init_2/stdout new file mode 100644 index 0000000..94ffd11 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_init_2/stdout @@ -0,0 +1,5 @@ +creating new :/test_space/kcl.mod +creating new :/test_space/kcl.mod.lock +creating new :/test_space/main.k +'/test_space/main.k' already exists +package 'test_space' init finished diff --git a/test/e2e/test_suites/test_kcl_mod_init_2/test_space/main.k b/test/e2e/test_suites/test_kcl_mod_init_2/test_space/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_init_2/test_space/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_pkg/input b/test/e2e/test_suites/test_kcl_mod_pkg/input new file mode 100644 index 0000000..948549d --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_pkg/input @@ -0,0 +1 @@ +kcl mod pkg --target /test_space \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_pkg/stderr b/test/e2e/test_suites/test_kcl_mod_pkg/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_pkg/stdout b/test/e2e/test_suites/test_kcl_mod_pkg/stdout new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_pkg/test_space/kcl.mod b/test/e2e/test_suites/test_kcl_mod_pkg/test_space/kcl.mod new file mode 100644 index 0000000..0c2f8cd --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_pkg/test_space/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "test_space" +edition = "v0.7.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_kcl_mod_pkg/test_space/kcl.mod.lock b/test/e2e/test_suites/test_kcl_mod_pkg/test_space/kcl.mod.lock new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_pkg/test_space/main.k b/test/e2e/test_suites/test_kcl_mod_pkg/test_space/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_pkg/test_space/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_pull/input b/test/e2e/test_suites/test_kcl_mod_pull/input new file mode 100644 index 0000000..522c616 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_pull/input @@ -0,0 +1 @@ +kcl mod pull helloworld \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_pull/stderr b/test/e2e/test_suites/test_kcl_mod_pull/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_pull/stdout b/test/e2e/test_suites/test_kcl_mod_pull/stdout new file mode 100644 index 0000000..da7ff38 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_pull/stdout @@ -0,0 +1,4 @@ +start to pull 'helloworld' +the lastest version '0.1.1' will be pulled +pulling 'test/helloworld:0.1.1' from 'localhost:5001/test/helloworld' +pulled 'helloworld' in '/test_space/localhost:5001/test/helloworld' successfully diff --git a/test/e2e/test_suites/test_kcl_mod_pull_0/input b/test/e2e/test_suites/test_kcl_mod_pull_0/input new file mode 100644 index 0000000..99a0c37 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_pull_0/input @@ -0,0 +1 @@ +kcl mod pull helloworld:0.1.1 \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_pull_0/stderr b/test/e2e/test_suites/test_kcl_mod_pull_0/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_pull_0/stdout b/test/e2e/test_suites/test_kcl_mod_pull_0/stdout new file mode 100644 index 0000000..33bda07 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_pull_0/stdout @@ -0,0 +1,3 @@ +start to pull 'helloworld:0.1.1' +pulling 'test/helloworld:0.1.1' from 'localhost:5001/test/helloworld' +pulled 'helloworld:0.1.1' in '/test_space/localhost:5001/test/helloworld/0.1.1' successfully diff --git a/test/e2e/test_suites/test_kcl_mod_pull_1/input b/test/e2e/test_suites/test_kcl_mod_pull_1/input new file mode 100644 index 0000000..67782bd --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_pull_1/input @@ -0,0 +1 @@ +kcl mod pull oci://localhost:5001/test/helloworld:0.1.1 \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_pull_1/stderr b/test/e2e/test_suites/test_kcl_mod_pull_1/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_pull_1/stdout b/test/e2e/test_suites/test_kcl_mod_pull_1/stdout new file mode 100644 index 0000000..31a4e44 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_pull_1/stdout @@ -0,0 +1,4 @@ +start to pull 'oci://localhost:5001/test/helloworld:0.1.1' +the lastest version '0.1.1' will be pulled +pulling '/test/helloworld:0.1.1:0.1.1' from 'localhost:5001/test/helloworld:0.1.1' +pulled 'oci://localhost:5001/test/helloworld:0.1.1' in '/test_space/localhost:5001/test/helloworld:0.1.1' successfully diff --git a/test/e2e/test_suites/test_kcl_mod_push/input b/test/e2e/test_suites/test_kcl_mod_push/input new file mode 100644 index 0000000..c22d4ef --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_push/input @@ -0,0 +1 @@ +kcl mod push \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_push/stderr b/test/e2e/test_suites/test_kcl_mod_push/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_push/stdout b/test/e2e/test_suites/test_kcl_mod_push/stdout new file mode 100644 index 0000000..918d1de --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_push/stdout @@ -0,0 +1,3 @@ +package 'test_space' will be pushed +pushed [registry] localhost:5001/test/test_space +digest: sha256: \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_push/test_space/kcl.mod b/test/e2e/test_suites/test_kcl_mod_push/test_space/kcl.mod new file mode 100644 index 0000000..c58a63b --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_push/test_space/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "test_space" +edition = "v0.8.0" +version = "0.0.2" + diff --git a/test/e2e/test_suites/test_kcl_mod_push/test_space/kcl.mod.lock b/test/e2e/test_suites/test_kcl_mod_push/test_space/kcl.mod.lock new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_push/test_space/main.k b/test/e2e/test_suites/test_kcl_mod_push/test_space/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_push/test_space/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_push_0/input b/test/e2e/test_suites/test_kcl_mod_push_0/input new file mode 100644 index 0000000..53e4bf4 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_push_0/input @@ -0,0 +1 @@ +kcl mod push oci://localhost:5001/myrepo:latest \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_push_0/stderr b/test/e2e/test_suites/test_kcl_mod_push_0/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_push_0/stdout b/test/e2e/test_suites/test_kcl_mod_push_0/stdout new file mode 100644 index 0000000..0fef751 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_push_0/stdout @@ -0,0 +1,3 @@ +package 'test_space' will be pushed +pushed [registry] localhost:5001/myrepo:latest +digest: sha256: \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_push_0/test_space/kcl.mod b/test/e2e/test_suites/test_kcl_mod_push_0/test_space/kcl.mod new file mode 100644 index 0000000..8e759df --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_push_0/test_space/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "test_space" +edition = "v0.8.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_kcl_mod_push_0/test_space/kcl.mod.lock b/test/e2e/test_suites/test_kcl_mod_push_0/test_space/kcl.mod.lock new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_push_0/test_space/main.k b/test/e2e/test_suites/test_kcl_mod_push_0/test_space/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_push_0/test_space/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_update/input b/test/e2e/test_suites/test_kcl_mod_update/input new file mode 100644 index 0000000..867076f --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_update/input @@ -0,0 +1 @@ +kcl mod update \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_update/stderr b/test/e2e/test_suites/test_kcl_mod_update/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_update/stdout b/test/e2e/test_suites/test_kcl_mod_update/stdout new file mode 100644 index 0000000..2f29bfc --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_update/stdout @@ -0,0 +1 @@ +adding 'helloworld' with version '0.1.1' diff --git a/test/e2e/test_suites/test_kcl_mod_update/test_space/kcl.mod b/test/e2e/test_suites/test_kcl_mod_update/test_space/kcl.mod new file mode 100644 index 0000000..7b58fda --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_update/test_space/kcl.mod @@ -0,0 +1,7 @@ +[package] +name = "test_space" +edition = "v0.8.0" +version = "0.0.1" + +[dependencies] +helloworld = "0.1.1" diff --git a/test/e2e/test_suites/test_kcl_mod_update/test_space/main.k b/test/e2e/test_suites/test_kcl_mod_update/test_space/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_update/test_space/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_update_0/input b/test/e2e/test_suites/test_kcl_mod_update_0/input new file mode 100644 index 0000000..0779920 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_update_0/input @@ -0,0 +1 @@ +kcl mod update /test_space/pkg \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_mod_update_0/stderr b/test/e2e/test_suites/test_kcl_mod_update_0/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_update_0/stdout b/test/e2e/test_suites/test_kcl_mod_update_0/stdout new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_mod_update_0/test_space/pkg/kcl.mod b/test/e2e/test_suites/test_kcl_mod_update_0/test_space/pkg/kcl.mod new file mode 100644 index 0000000..05d264c --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_update_0/test_space/pkg/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "pkg" +edition = "v0.8.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_kcl_mod_update_0/test_space/pkg/main.k b/test/e2e/test_suites/test_kcl_mod_update_0/test_space/pkg/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_mod_update_0/test_space/pkg/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_run/input b/test/e2e/test_suites/test_kcl_run/input new file mode 100644 index 0000000..b3a8797 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run/input @@ -0,0 +1 @@ +kcl run /test_space/main.k \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_run/stderr b/test/e2e/test_suites/test_kcl_run/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_run/stdout b/test/e2e/test_suites/test_kcl_run/stdout new file mode 100644 index 0000000..d2dcf2a --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run/stdout @@ -0,0 +1 @@ +The_first_kcl_program: Hello World! diff --git a/test/e2e/test_suites/test_kcl_run/test_space/main.k b/test/e2e/test_suites/test_kcl_run/test_space/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run/test_space/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_run_0/input b/test/e2e/test_suites/test_kcl_run_0/input new file mode 100644 index 0000000..b493529 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run_0/input @@ -0,0 +1 @@ +kcl run /test_space/main.k --format json \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_run_0/stderr b/test/e2e/test_suites/test_kcl_run_0/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_run_0/stdout b/test/e2e/test_suites/test_kcl_run_0/stdout new file mode 100644 index 0000000..4864e28 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run_0/stdout @@ -0,0 +1,3 @@ +{ + "The_first_kcl_program": "Hello World!" +} diff --git a/test/e2e/test_suites/test_kcl_run_0/test_space/main.k b/test/e2e/test_suites/test_kcl_run_0/test_space/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run_0/test_space/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_run_1/input b/test/e2e/test_suites/test_kcl_run_1/input new file mode 100644 index 0000000..81c6fff --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run_1/input @@ -0,0 +1 @@ +kcl run /test_space/run.k /test_space/run1.k \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_run_1/stderr b/test/e2e/test_suites/test_kcl_run_1/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_run_1/stdout b/test/e2e/test_suites/test_kcl_run_1/stdout new file mode 100644 index 0000000..0b3b536 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run_1/stdout @@ -0,0 +1,2 @@ +run: Hello World! +run_1: Hello World 1 ! diff --git a/test/e2e/test_suites/test_kcl_run_1/test_space/run.k b/test/e2e/test_suites/test_kcl_run_1/test_space/run.k new file mode 100644 index 0000000..850ceae --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run_1/test_space/run.k @@ -0,0 +1 @@ +run = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_run_1/test_space/run1.k b/test/e2e/test_suites/test_kcl_run_1/test_space/run1.k new file mode 100644 index 0000000..da222b2 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run_1/test_space/run1.k @@ -0,0 +1 @@ +run_1 = 'Hello World 1 !' \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_run_2/input b/test/e2e/test_suites/test_kcl_run_2/input new file mode 100644 index 0000000..6303a69 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run_2/input @@ -0,0 +1 @@ +kcl run oci://localhost:5001/test/helloworld \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_run_2/stderr b/test/e2e/test_suites/test_kcl_run_2/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_run_2/stdout b/test/e2e/test_suites/test_kcl_run_2/stdout new file mode 100644 index 0000000..deedd47 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run_2/stdout @@ -0,0 +1,3 @@ +the lastest version '0.1.1' will be pulled +pulling '/test/helloworld:0.1.1' from 'localhost:5001/test/helloworld' +The_first_kcl_program: Hello World! diff --git a/test/e2e/test_suites/test_kcl_run_3/input b/test/e2e/test_suites/test_kcl_run_3/input new file mode 100644 index 0000000..12aa491 --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run_3/input @@ -0,0 +1 @@ +kcl run \ No newline at end of file diff --git a/test/e2e/test_suites/test_kcl_run_3/stderr b/test/e2e/test_suites/test_kcl_run_3/stderr new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_run_3/stdout b/test/e2e/test_suites/test_kcl_run_3/stdout new file mode 100644 index 0000000..d2dcf2a --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run_3/stdout @@ -0,0 +1 @@ +The_first_kcl_program: Hello World! diff --git a/test/e2e/test_suites/test_kcl_run_3/test_space/kcl.mod b/test/e2e/test_suites/test_kcl_run_3/test_space/kcl.mod new file mode 100644 index 0000000..8e759df --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run_3/test_space/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "test_space" +edition = "v0.8.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_kcl_run_3/test_space/kcl.mod.lock b/test/e2e/test_suites/test_kcl_run_3/test_space/kcl.mod.lock new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/test_suites/test_kcl_run_3/test_space/main.k b/test/e2e/test_suites/test_kcl_run_3/test_space/main.k new file mode 100644 index 0000000..fa7048e --- /dev/null +++ b/test/e2e/test_suites/test_kcl_run_3/test_space/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/utils.go b/test/e2e/utils.go new file mode 100644 index 0000000..72e15a9 --- /dev/null +++ b/test/e2e/utils.go @@ -0,0 +1,96 @@ +package e2e + +import ( + "io" + "log" + "os" + "sort" + "strings" + + "github.com/otiai10/copy" + "github.com/thoas/go-funk" + "kcl-lang.io/kpm/pkg/reporter" +) + +// Copy will copy file from 'srcPath' to 'dstPath'. +func Copy(srcPath, dstPath string) { + src, err := os.Open(srcPath) + if err != nil { + log.Fatal(err) + } + defer src.Close() + + dst, err := os.Create(dstPath) + if err != nil { + log.Fatal(err) + } + defer dst.Close() + + _, err = io.Copy(dst, src) + if err != nil { + log.Fatal(err) + } +} + +// CopyDir will copy dir from 'srcDir' to 'dstDir'. +func CopyDir(srcDir, dstDir string) { + err := copy.Copy(srcDir, dstDir) + if err != nil { + reporter.ExitWithReport("failed to copy dir.") + } +} + +var KEYS = []string{"", "", "", ""} + +// IsIgnore will reture whether the expected result in 'expectedStr' should be ignored. +func IsIgnore(expectedStr string) bool { + return strings.Contains(expectedStr, "") +} + +// ReplaceAllKeyByValue will replace all 'key's by 'value' in 'originStr'. +func ReplaceAllKeyByValue(originStr, key, value string) string { + if !funk.Contains(KEYS, key) { + reporter.ExitWithReport("unknown key.", key) + } else { + return strings.ReplaceAll(originStr, key, value) + } + + return originStr +} + +// SplitCommand will spilt command string into []string, +// but the string in quotes will not be cut. +// If 'command' is 'aaa bbb "ccc ddd"', SplitCommand will return ["aaa", "bbb", "ccc ddd"]. +func SplitCommand(command string) []string { + var args []string + var currentArg string + inQuotes := false + for _, char := range command { + if char == '"' { + inQuotes = !inQuotes + continue + } + if char == ' ' && !inQuotes { + args = append(args, currentArg) + currentArg = "" + continue + } + currentArg += string(char) + } + if currentArg != "" { + args = append(args, currentArg) + } + return args +} + +// RemoveLineOrder will remove the line order in 'str1'. +func RemoveLineOrder(str1 string) string { + // Split the strings into slices of lines + lines1 := strings.Split(str1, "\n") + + // Sort the slices of lines + sort.Strings(lines1) + + // Compare the sorted slices of lines + return strings.Join(lines1, "\n") +}