test: module clash across packages (#11246)
This PR adds a test that covers importing modules defined in multiple packages. Currently, will resolve the module to its first occurrence in the its search order. However, this will soon change, so this test is designed to analyze that behavior.
This commit is contained in:
parent
8a0ee9aac7
commit
687698e79d
12 changed files with 53 additions and 0 deletions
1
tests/pkg/.gitignore
vendored
1
tests/pkg/.gitignore
vendored
|
|
@ -1 +1,2 @@
|
|||
lake-manifest.json
|
||||
produced.out
|
||||
|
|
|
|||
3
tests/pkg/mod_clash/Test/ImportDiff.lean
Normal file
3
tests/pkg/mod_clash/Test/ImportDiff.lean
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import Diff
|
||||
|
||||
def testDiff := foo
|
||||
3
tests/pkg/mod_clash/Test/ImportSame.lean
Normal file
3
tests/pkg/mod_clash/Test/ImportSame.lean
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import Same
|
||||
|
||||
def testSame := same
|
||||
3
tests/pkg/mod_clash/clean.sh
Executable file
3
tests/pkg/mod_clash/clean.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
rm -rf .lake lake-manifest.json produced.out
|
||||
rm -rf depA/.lake depA/lake-manifest.json
|
||||
rm -rf depB/.lake depB/lake-manifest.json
|
||||
1
tests/pkg/mod_clash/depA/Diff.lean
Normal file
1
tests/pkg/mod_clash/depA/Diff.lean
Normal file
|
|
@ -0,0 +1 @@
|
|||
def foo := "depA"
|
||||
1
tests/pkg/mod_clash/depA/Same.lean
Normal file
1
tests/pkg/mod_clash/depA/Same.lean
Normal file
|
|
@ -0,0 +1 @@
|
|||
def same := 0
|
||||
7
tests/pkg/mod_clash/depA/lakefile.toml
Normal file
7
tests/pkg/mod_clash/depA/lakefile.toml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
name = "depA"
|
||||
|
||||
[[lean_lib]]
|
||||
name = "Same"
|
||||
|
||||
[[lean_lib]]
|
||||
name = "Diff"
|
||||
1
tests/pkg/mod_clash/depB/Diff.lean
Normal file
1
tests/pkg/mod_clash/depB/Diff.lean
Normal file
|
|
@ -0,0 +1 @@
|
|||
def bar := "depB"
|
||||
1
tests/pkg/mod_clash/depB/Same.lean
Normal file
1
tests/pkg/mod_clash/depB/Same.lean
Normal file
|
|
@ -0,0 +1 @@
|
|||
def same := 0
|
||||
7
tests/pkg/mod_clash/depB/lakefile.toml
Normal file
7
tests/pkg/mod_clash/depB/lakefile.toml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
name = "depB"
|
||||
|
||||
[[lean_lib]]
|
||||
name = "Same"
|
||||
|
||||
[[lean_lib]]
|
||||
name = "Diff"
|
||||
12
tests/pkg/mod_clash/lakefile.toml
Normal file
12
tests/pkg/mod_clash/lakefile.toml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
name = "test"
|
||||
|
||||
[[lean_lib]]
|
||||
name = "Test"
|
||||
|
||||
[[require]]
|
||||
name = "depA"
|
||||
path = "depA"
|
||||
|
||||
[[require]]
|
||||
name = "depB"
|
||||
path = "depB"
|
||||
13
tests/pkg/mod_clash/test.sh
Executable file
13
tests/pkg/mod_clash/test.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
source ../../lake/tests/common.sh
|
||||
|
||||
# This test covers importing modules which are defined in multiple packages.
|
||||
|
||||
./clean.sh
|
||||
test_run resolve-deps
|
||||
|
||||
# Test that importing a module with multiple equivalent candidates works
|
||||
test_run build Test.ImportSame
|
||||
|
||||
# Test that importing a module with multiple distinct candidates fails
|
||||
test_err 'Unknown identifier `foo`' build Test.ImportDiff
|
||||
Loading…
Add table
Reference in a new issue