From 1a8150ecffd529df4a364271cec15b4322fb89b5 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Tue, 14 May 2024 18:30:08 +0200 Subject: [PATCH] added a test --- .../check/tests/BinaryDependencyTest.rsc | 84 ++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/BinaryDependencyTest.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/BinaryDependencyTest.rsc index 3be1ac4c..060cc162 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/BinaryDependencyTest.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/tests/BinaryDependencyTest.rsc @@ -10,7 +10,8 @@ import lang::rascalcore::check::Import; data PathConfig(loc resources=|unknown:///|, loc generatedSources=|unknown:///|); test bool importSimpleBinaryModule() { - lang::rascalcore::check::Import::traceTPL = true; + remove(|memory://myTestLibrary/|, recursive=true); + remove(|memory://myTestLibraryClient|, recursive=true); // First we compile a library writeFile(|memory://myTestLibrary/src/A.rsc|, @@ -60,3 +61,84 @@ test bool importSimpleBinaryModule() { return true; } + +test bool importTransitiveBinaryModule() { + remove(|memory://myTestLibrary/|, recursive=true); + remove(|memory://myTestLibraryClient|, recursive=true); + remove(|memory://myTestClient|, recursive=true); + + + // First we compile a library + writeFile(|memory://myTestLibrary/src/A.rsc|, + "module A + ' + 'int aFunction() = 1; + "); + + pcfgLib = pathConfig( + srcs=[|memory://myTestLibrary/src|], + bin=|memory://myTestLibrary/bin|, + generatedSources=|memory://myTestLibrary/generated|, + resources=|memory://myTestLibrary/resources|, + libs=[] + ); + + // this compiles A and stores in pcfg.resources/rascal/$A.tpl + msgs = check([|memory://myTestLibrary/src/A.rsc|], rascalCompilerConfig(pcfgLib)); + + // 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 + "); + + pcfgLibraryClient = 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(pcfgLibraryClient)); + + // again 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://myTestLibraryClient/src|, recursive=true); + + // Now we compile a client + writeFile(|memory://myTestClient/src/C.rsc|, + "module C + ' + 'extend B; // library import that itself depends on another library + 'int cFunction() = bFunction() + aFunction(); // library usage from two levels of extend + "); + + pcfgClient = pathConfig( + srcs=[|memory://myTestClient/src|], + bin=|memory://myTestClient/bin|, + generatedSources=|memory://myTestClient/generated|, + resources=|memory://myTestClient/resources|, + libs=[|memory://myTestLibrary/resources| // library dependency on where the .tpl files are + ,|memory://myTestLibraryClient/resources|] // for both projects we depend on + ); + + msgs = check([|memory://myTestLibraryClient/src/C.rsc|], rascalCompilerConfig(pcfgLibraryClient)); + + // again no issues expected + assert all(program(_,{}) <- msgs) : ""; + + return true; +}