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:
Mac Malone 2025-11-18 21:23:34 -05:00 committed by GitHub
parent 8a0ee9aac7
commit 687698e79d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 53 additions and 0 deletions

View file

@ -1 +1,2 @@
lake-manifest.json
produced.out

View file

@ -0,0 +1,3 @@
import Diff
def testDiff := foo

View file

@ -0,0 +1,3 @@
import Same
def testSame := same

3
tests/pkg/mod_clash/clean.sh Executable file
View 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

View file

@ -0,0 +1 @@
def foo := "depA"

View file

@ -0,0 +1 @@
def same := 0

View file

@ -0,0 +1,7 @@
name = "depA"
[[lean_lib]]
name = "Same"
[[lean_lib]]
name = "Diff"

View file

@ -0,0 +1 @@
def bar := "depB"

View file

@ -0,0 +1 @@
def same := 0

View file

@ -0,0 +1,7 @@
name = "depB"
[[lean_lib]]
name = "Same"
[[lean_lib]]
name = "Diff"

View 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
View 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