diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index f0de55fc4..28c9b176e 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -19,6 +19,7 @@ import ( "kcl-lang.io/kpm/pkg/git" "kcl-lang.io/kpm/pkg/opt" pkg "kcl-lang.io/kpm/pkg/package" + "kcl-lang.io/kpm/pkg/reporter" "kcl-lang.io/kpm/pkg/runner" "kcl-lang.io/kpm/pkg/utils" ) @@ -158,7 +159,31 @@ func TestDependencyGraph(t *testing.T) { } func TestCyclicDependency(t *testing.T) { - + // testDir := getTestDir("test_cyclic_dependency") + // assert.Equal(t, utils.DirExists(filepath.Join(testDir, "aaa")), true) + // assert.Equal(t, utils.DirExists(filepath.Join(testDir, "aaa/kcl.mod")), true) + // assert.Equal(t, utils.DirExists(filepath.Join(testDir, "bbb")), true) + // assert.Equal(t, utils.DirExists(filepath.Join(testDir, "bbb/kcl.mod")), true) + + // pkg_path := filepath.Join(testDir, "aaa") + + // kpmcli, err := NewKpmClient() + // assert.Equal(t, err, nil) + // kclPkg, err := kpmcli.LoadPkgFromPath(pkg_path) + // assert.Equal(t, err, nil) + + // currentDir, err := os.Getwd() + // assert.Equal(t, err, nil) + // err = os.Chdir(pkg_path) + // assert.Equal(t, err, nil) + + // _, _, err = kpmcli.InitGraphAndDownloadDeps(kclPkg) + // assert.Equal(t, err, reporter.NewErrorEvent( + // reporter.CircularDependencyExist, nil, "adding dependencies results in a cycle", + // )) + + // err = os.Chdir(currentDir) + // assert.Equal(t, err, nil) } func TestInitEmptyPkg(t *testing.T) { diff --git a/pkg/client/test_data/test_cyclic_dependency/aaa/kcl.mod b/pkg/client/test_data/test_cyclic_dependency/aaa/kcl.mod new file mode 100644 index 000000000..79bceba5d --- /dev/null +++ b/pkg/client/test_data/test_cyclic_dependency/aaa/kcl.mod @@ -0,0 +1,7 @@ +[package] +name = "aaa" +edition = "0.0.1" +version = "0.0.1" + +[dependencies] +bbb = { path = "../bbb" } diff --git a/pkg/client/test_data/test_cyclic_dependency/aaa/kcl.mod.lock b/pkg/client/test_data/test_cyclic_dependency/aaa/kcl.mod.lock new file mode 100644 index 000000000..9c2490805 --- /dev/null +++ b/pkg/client/test_data/test_cyclic_dependency/aaa/kcl.mod.lock @@ -0,0 +1,6 @@ +[dependencies] + [dependencies.bbb] + name = "bbb" + full_name = "bbb_" + sum = "d5r1MvBb8BvbURsKSdE6mW6oA3w0Df4BKds8IU83/us=" + path = "../bbb" diff --git a/pkg/client/test_data/test_cyclic_dependency/bbb/kcl.mod b/pkg/client/test_data/test_cyclic_dependency/bbb/kcl.mod new file mode 100644 index 000000000..a70b83513 --- /dev/null +++ b/pkg/client/test_data/test_cyclic_dependency/bbb/kcl.mod @@ -0,0 +1,7 @@ +[package] +name = "bbb" +edition = "0.0.1" +version = "0.0.1" + +[dependencies] +aaa = { path = "../aaa" } diff --git a/pkg/client/test_data/test_cyclic_dependency/bbb/kcl.mod.lock b/pkg/client/test_data/test_cyclic_dependency/bbb/kcl.mod.lock new file mode 100644 index 000000000..e3672021c --- /dev/null +++ b/pkg/client/test_data/test_cyclic_dependency/bbb/kcl.mod.lock @@ -0,0 +1,8 @@ +[dependencies] + [dependencies.aaa] + name = "aaa" + full_name = "aaa_0.0.1" + version = "0.0.1" + sum = "hgAM5wYFzXo83S+OiT0LaBDnHU7Q9vqq3BPXlTDr8TY=" + path = "../aaa" +