-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added failing test for importing a "binary" tpl file
- Loading branch information
1 parent
bc85fde
commit 67a8212
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
src/org/rascalmpl/core/library/lang/rascalcore/check/tests/BinaryDependencyTest.rsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
@synopsis{Tests if we can typecheck Rascal modules that import and use other modules that | ||
are only available as .tpl files on the libs path.} | ||
module lang::rascalcore::check::tests::BinaryDependencyTest | ||
|
||
import lang::rascalcore::check::Checker; | ||
import util::Reflective; | ||
import IO; | ||
import lang::rascalcore::check::Import; | ||
|
||
data PathConfig(loc resources=|unknown:///|, loc generatedSources=|unknown:///|); | ||
|
||
test bool importSimpleBinaryModule() { | ||
lang::rascalcore::check::Import::traceTPL = true; | ||
|
||
// First we compile a library | ||
writeFile(|memory://myTestLibrary/src/A.rsc|, | ||
"module A | ||
' | ||
'int aFunction() = 1; | ||
"); | ||
|
||
|
||
|
||
pcfg = pathConfig( | ||
srcs=[|memory://myTestLibrary/src|], | ||
bin=|memory://myTestLibrary/bin|, | ||
generatedSources=|memory://myTestLibrary/generated|, | ||
resources=|memory://myTestLibrary/resources|, | ||
libs=[] | ||
); | ||
|
||
// this transitively compiles A and stores in pcfg.bin/rascal/$A.tpl | ||
msgs = check([|memory://myTestLibrary/src/A.rsc|], rascalCompilerConfig(pcfg)); | ||
|
||
// no issues expected | ||
assert all(program(_,{}) <- msgs); | ||
|
||
// just to make sure no source code leaks into the following, | ||
// we remove the entire source file from existence | ||
remove(|memory://myTestLibrary/src|, recursive=true); | ||
|
||
// Now we compile a client | ||
writeFile(|memory://myTestLibraryClient/src/B.rsc|, | ||
"module B | ||
' | ||
'import A; // library import | ||
'int bFunction() = aFunction(); // library usage | ||
"); | ||
|
||
pcfg = pathConfig( | ||
srcs=[|memory://myTestLibraryClient/src|], | ||
bin=|memory://myTestLibraryClient/bin|, | ||
generatedSources=|memory://myTestLibraryClient/generated|, | ||
resources=|memory://myTestLibraryClient/resources|, | ||
libs=[|memory://myTestLibrary/resources|] // library dependency on where the .tpl files are | ||
); | ||
|
||
msgs = check([|memory://myTestLibraryClient/src/B.rsc|], rascalCompilerConfig(pcfg)); | ||
|
||
// again no issues expected | ||
assert all(program(_,{}) <- msgs) : "<msgs>"; | ||
|
||
return true; | ||
} |