Skip to content

Commit

Permalink
chore: testing stdlib-import-root
Browse files Browse the repository at this point in the history
  • Loading branch information
vknabel committed Mar 6, 2022
1 parent 5db80b2 commit afd978e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions resolution/module-resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ type ModuleResolver struct {
lithiaSourceGlob string
}

func DefaultModuleResolver() ModuleResolver {
func DefaultModuleResolver(importRoots ...string) ModuleResolver {
return ModuleResolver{
externalImportRoots: defaultImportRoots(),
externalImportRoots: defaultImportRoots(importRoots...),
defaultPackageName: "root",
manifestName: "Potfile",
manifestSearchPaths: []string{".", "..", "../..", "../../..", "../../../.."},
Expand Down Expand Up @@ -52,8 +52,8 @@ type PackageManifest struct {
Path string
}

func defaultImportRoots() []string {
roots := []string{}
func defaultImportRoots(importRoots ...string) []string {
roots := importRoots
if path, ok := os.LookupEnv("LITHIA_LOCALS"); ok {
roots = append(roots, path)
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Interpreter struct {

func NewInterpreter(referenceFile string, importRoots ...string) *Interpreter {
inter := &Interpreter{
Resolver: resolution.DefaultModuleResolver(),
Resolver: resolution.DefaultModuleResolver(importRoots...),
Parser: parser.NewParser(),
Modules: make(map[ast.ModuleName]*RuntimeModule),
ExternalDefinitions: make(map[ast.ModuleName]ExternalDefinition),
Expand Down
2 changes: 1 addition & 1 deletion runtime/runtime-stdlib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func TestStdlib(t *testing.T) {
pathToStdlib := "../stdlib"
inter := r.NewInterpreter(pathToStdlib)
inter := r.NewInterpreter(pathToStdlib, "../stdlib")
mockOS := &mockExternalOS{
calledExitCode: -1,
env: map[string]string{"LITHIA_TESTS": "1"},
Expand Down

0 comments on commit afd978e

Please sign in to comment.