Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 9c89949

Browse files
committed
Partially rewritten tests to use mvn scheme
1 parent de0a30f commit 9c89949

File tree

5 files changed

+175
-113
lines changed

5 files changed

+175
-113
lines changed

src/org/rascalmpl/core/library/lang/rascalcore/check/TestConfigs.rsc

Lines changed: 133 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module lang::rascalcore::check::TestConfigs
22

3+
import IO;
34
import util::Reflective;
45
import lang::rascalcore::check::BasicRascalConfig;
56
import lang::rascalcore::check::RascalConfig;
@@ -14,10 +15,22 @@ data PathConfig(
1415

1516
// ---- Various PathConfigs ---------------------------------------------
1617

17-
loc REPO = |file:///Users/paulklint/git/|;
18-
loc RASCAL_JAR = |jar+file:///Users/paulklint/.m2/repository/org/rascalmpl/rascal/0.40.17/rascal-0.40.17.jar!/|;
19-
loc TYPEPAL_JAR = |jar+file:///Users/paulklint/.m2/repository/org/rascalmpl/typepal/0.14.8/typepal-0.14.8.jar!/|;
20-
loc OUTDATED_TYPEPAL_JAR = |jar+file:///Users/paulklint/.m2/repository/org/rascalmpl/typepal/0.14.1/typepal-0.14.1.jar!/|;
18+
loc RASCAL = |mvn://org.rascalmpl!rascal!0.40.17/!|;
19+
loc TYPEPAL = |mvn://org.rascalmpl!typepal!0.14.8/!|;
20+
loc OUTDATED_TYPEPAL
21+
= |mvn://org.rascalmpl!typepal!0.14.1/!|;
22+
loc RASCAL_CORE = |mvn://org.rascalmpl!rascal-core!0.12.14/!|;
23+
24+
loc DRAMBIGUITY = |mvn://org.rascalmpl!drambiguity!0.1.2/!|;
25+
loc FLYBYTES = |mvn://org.rascalmpl!flybytes!0.1.5/!|;
26+
loc SALIX_CORE = |mvn://org.rascalmpl!salix-core!0.2.7/!|;
27+
loc SALIX_CONTRIB = |mvn://org.rascalmpl!salix-contrib!0.2.7/!|;
28+
loc RASCAL_LSP = |mvn://org.rascalmpl!rascal-language-server!0.12.1/!|;
29+
loc PHP_ANALYSIS = |mvn://org.rascalmpl!php-analysis!0.2.5-SNAPSHOT/!|;
30+
31+
loc REPO = |file:///Users/paulklint/git/|;
32+
loc COMPILED_RASCAL
33+
= REPO + "compiled-rascal";
2134

2235
// ---- PathConfigs for testing purposes --------------------------------------
2336

@@ -72,43 +85,83 @@ public PathConfig getRascalProjectTestingPathConfig() {
7285

7386
// ---- generic template for PathConfigs --------------------------------------
7487

75-
public PathConfig makePathConfig(list[loc] sources, list[loc] libraries) {
76-
return pathConfig(
77-
srcs = sources,
78-
bin = REPO + "compiled-rascal/target/classes",
79-
generatedSources = REPO + "compiled-rascal/src/main/java",
80-
generatedTestSources = REPO + "compiled-rascal/src/test/java/",
81-
resources = REPO + "compiled-rascal/src/main/java",
82-
testResources = REPO + "compiled-rascal/src/test/java",
83-
libs = libraries
84-
);
88+
public PathConfig makePathConfig(loc repo, list[loc] sources, list[loc] libraries, bool compiler = false) {
89+
return pathConfig(
90+
srcs = sources,
91+
bin = compiler ? COMPILED_RASCAL + "/target/classes" : repo,
92+
generatedSources = compiler ? COMPILED_RASCAL + "/src/main/java" : |unknown:///|,
93+
generatedTestSources = compiler ? COMPILED_RASCAL + "/src/test/java/" : |unknown:///|,
94+
resources = compiler ? COMPILED_RASCAL + "/src/main/java" : repo + "/rascal",
95+
testResources = compiler ? COMPILED_RASCAL + "/src/test/java/" : repo + "/rascal",
96+
libs = libraries
97+
);
8598
}
8699

87100
// --- all source ------------------------------------------------------------
88101

89-
public PathConfig getAllSrcPathConfig() {
90-
return makePathConfig([ REPO + "rascal/src/org/rascalmpl/library",
91-
REPO + "rascal/test/org/rascalmpl/benchmark/",
92-
REPO + "rascal-core/src/org/rascalmpl/core/library",
93-
REPO + "typepal/src"
102+
public PathConfig getAllSrcPathConfig(bool compiler = true) {
103+
return makePathConfig(COMPILED_RASCAL,
104+
[ RASCAL + "org/rascalmpl/library",
105+
RASCAL + "org/rascalmpl/benchmark/",
106+
RASCAL_CORE + "org/rascalmpl/core/library",
107+
TYPEPAL
108+
],
109+
[ ],
110+
compiler=compiler);
111+
}
112+
113+
public RascalCompilerConfig getAllSrcCompilerConfig(bool compiler=true){
114+
return rascalCompilerConfig(getAllSrcPathConfig(compiler=compiler))[verbose = true][logWrittenFiles=true];
115+
}
116+
117+
public PathConfig getAllSrcWritablePathConfig(bool compiler = true) {
118+
TMP_RASCAL = |tmp:///rascal/|;
119+
TMP_RASCAL_CORE = |tmp:///rascal-core/|;
120+
TMP_TYPEPAL = |tmp:///typepal/|;
121+
copy(RASCAL, TMP_RASCAL, recursive=true, overwrite=true);
122+
copy(RASCAL_CORE, TMP_RASCAL_CORE, recursive=true, overwrite=true);
123+
copy(TYPEPAL, TMP_TYPEPAL, recursive=true, overwrite=true);
124+
return makePathConfig(COMPILED_RASCAL,
125+
[ TMP_RASCAL + "org/rascalmpl/library",
126+
TMP_RASCAL + "org/rascalmpl/benchmark/",
127+
TMP_RASCAL_CORE + "org/rascalmpl/core/library",
128+
TMP_TYPEPAL
94129
],
95-
[ ]);
130+
[ ],
131+
compiler=compiler);
96132
}
97133

98-
public RascalCompilerConfig getAllSrcCompilerConfig(){
99-
return rascalCompilerConfig(getAllSrcPathConfig())[verbose = true][logWrittenFiles=true];
134+
public RascalCompilerConfig getAllSrcWritableCompilerConfig(bool compiler=true){
135+
return rascalCompilerConfig(getAllSrcWritablePathConfig(compiler=compiler))[verbose = true][logWrittenFiles=true];
100136
}
101137

102138
// ---- rascal ----------------------------------------------------------------
139+
public PathConfig getRascalPathConfig(bool compiler = false) {
140+
return makePathConfig(RASCAL,
141+
[ RASCAL + "org/rascalmpl/library"
142+
//, RASCAL + "test/org/rascalmpl/benchmark/"
143+
],
144+
[],
145+
compiler=compiler);
146+
}
147+
148+
public RascalCompilerConfig getRascalCompilerConfig(bool compiler=true){
149+
return rascalCompilerConfig(getRascalPathConfig(compiler=compiler))[verbose = true][logWrittenFiles=true];
150+
}
103151

104-
public PathConfig getRascalPathConfig() {
105-
return makePathConfig([ REPO + "rascal/src/org/rascalmpl/library",
106-
REPO + "rascal/test/org/rascalmpl/benchmark/" ],
107-
[ ]);
152+
public PathConfig getRascalWritablePathConfig(bool compiler = true) {
153+
TMP_RASCAL = |tmp:///rascal/|;
154+
copy(RASCAL, TMP_RASCAL, recursive=true, overwrite=true);
155+
return makePathConfig(TMP_RASCAL,
156+
[ TMP_RASCAL + "org/rascalmpl/library"
157+
//, RASCAL + "test/org/rascalmpl/benchmark/"
158+
],
159+
[],
160+
compiler=compiler);
108161
}
109162

110-
public RascalCompilerConfig getRascalCompilerConfig(){
111-
return rascalCompilerConfig(getRascalPathConfig())[verbose = true][logWrittenFiles=true];
163+
public RascalCompilerConfig getRascalCompilerConfig(bool compiler=true){
164+
return rascalCompilerConfig(getRascalWritablePathConfig(compiler=compiler))[verbose = true][logWrittenFiles=true];
112165
}
113166

114167
// ---- rascal-core -----------------------------------------------------------
@@ -119,13 +172,15 @@ public RascalCompilerConfig getRascalCompilerConfig(){
119172
* binaries will be stored the target folder of the rascal-core project
120173
* has the standard library and typepal on the library path, in case you accidentally want to test a module in rascal-core which depends on typepal.
121174
}
122-
public PathConfig getRascalCorePathConfig() {
123-
return makePathConfig([ REPO + "rascal-core/src/org/rascalmpl/core/library" ],
124-
[ RASCAL_JAR, TYPEPAL_JAR ]);
175+
public PathConfig getRascalCorePathConfig(bool compiler = false) {
176+
return makePathConfig(RASCAL_CORE,
177+
[ RASCAL_CORE + "org/rascalmpl/core/library" ],
178+
[ RASCAL, TYPEPAL ],
179+
compiler=compiler);
125180
}
126181

127-
public RascalCompilerConfig getRascalCoreCompilerConfig(){
128-
return rascalCompilerConfig(getRascalCorePathConfig())[verbose = true][logWrittenFiles=true];
182+
public RascalCompilerConfig getRascalCoreCompilerConfig(bool compiler=true){
183+
return rascalCompilerConfig(getRascalCorePathConfig(compiler=compiler))[verbose = true][logWrittenFiles=true];
129184
}
130185

131186
@synopsis{Developers version: PathConfig for type-checking modules in other (named) Rascal projects}
@@ -136,8 +191,7 @@ public RascalCompilerConfig getRascalCoreCompilerConfig(){
136191
* Included projects: rascal-tutor, flybytes, rascal-lsp
137192
}
138193
public PathConfig getRascalCorePathConfigDev() {
139-
return makePathConfig([ REPO + "rascal-core/src" ],
140-
[ RASCAL_JAR, TYPEPAL_JAR ]);
194+
return makePathConfig(RASCAL_CORE, [ RASCAL_CORE ], [ RASCAL, TYPEPAL ], compiler=compiler);
141195
}
142196

143197
public RascalCompilerConfig getRascalCoreCompilerConfigDev(){
@@ -146,68 +200,77 @@ public RascalCompilerConfig getRascalCoreCompilerConfigDev(){
146200

147201
// ---- typepal ---------------------------------------------------------------
148202

149-
public PathConfig getTypePalProjectPathConfig() {
150-
return makePathConfig([ REPO + "typepal/src" ],
151-
[ RASCAL_JAR ]);
203+
public PathConfig getTypePalProjectPathConfig(bool compiler = false) {
204+
return makePathConfig(TYPEPAL,
205+
[ TYPEPAL ],
206+
[ RASCAL ],
207+
compiler=compiler);
152208
}
153209

154-
public RascalCompilerConfig getTypePalCompilerConfig(){
155-
return rascalCompilerConfig(getTypePalProjectPathConfig())[verbose = true][logWrittenFiles=true];
210+
public RascalCompilerConfig getTypePalCompilerConfig(bool compiler=true){
211+
return rascalCompilerConfig(getTypePalProjectPathConfig(compiler=compiler))[verbose = true][logWrittenFiles=true];
156212
}
157213

158214
// ---- flybytes --------------------------------------------------------------
159215

160-
public PathConfig getFlyBytesProjectPathConfig() {
161-
return makePathConfig([ REPO + "flybytes/src" ],
162-
[ RASCAL_JAR ]);
216+
public PathConfig getFlyBytesProjectPathConfig(bool compiler = false) {
217+
return makePathConfig(FLYBYTES, [ FLYBYTES ], [ RASCAL ], compiler=compiler);
163218
}
164219

165-
public RascalCompilerConfig getFlyBytesCompilerConfig(){
166-
return rascalCompilerConfig(getFlyBytesProjectPathConfig())[verbose = true][logWrittenFiles=true];
220+
public RascalCompilerConfig getFlyBytesCompilerConfig(bool compiler=true){
221+
return rascalCompilerConfig(getFlyBytesProjectPathConfig(compiler=compiler))[verbose = true][logWrittenFiles=true];
167222
}
168223

169224
// ---- salix -----------------------------------------------------------------
170225

171-
public PathConfig getSalixPathConfig() {
172-
return makePathConfig([ REPO + "salix-core/src/main/rascal", REPO + "salix-contrib/src/main/rascal" ],
173-
[ RASCAL_JAR ]);
226+
public PathConfig getSalixPathConfig(bool compiler = false) {
227+
return makePathConfig(SALIX_CORE,
228+
[ SALIX_CORE + "src/main/rascal", SALIX_CONTRIB + "src/main/rascal" ],
229+
[ RASCAL ],
230+
compiler=compiler);
174231
}
175232

176-
public RascalCompilerConfig getSalixCompilerConfig(){
177-
return rascalCompilerConfig(getSalixPathConfig())[verbose = true][logWrittenFiles=true];
233+
public RascalCompilerConfig getSalixCompilerConfig(bool compiler = true){
234+
return rascalCompilerConfig(getSalixPathConfig(compiler=compiler))[verbose = true][logWrittenFiles=true];
178235
}
179236

180237
// ---- drambiguity -----------------------------------------------------------
181238

182239
public PathConfig getDrAmbiguityPathConfig() {
183-
return makePathConfig([ REPO + "drambiguity/src", REPO + "salix-core/src/main/rascal" ],
184-
[ RASCAL_JAR ]);
240+
return makePathConfig(DRAMBIGUITY,
241+
[ DRAMBIGUITY, SALIX_CORE + "src/main/rascal" ],
242+
[ RASCAL ],
243+
compiler=compiler);
185244
}
186245

187-
public RascalCompilerConfig getDrAmbiguityCompilerConfig(){
188-
return rascalCompilerConfig(getDrAmbiguityPathConfig())[verbose = true][logWrittenFiles=true];
246+
public RascalCompilerConfig getDrAmbiguityCompilerConfig(bool compiler = true){
247+
return rascalCompilerConfig(getDrAmbiguityPathConfig(compiler=compiler))[verbose = true][logWrittenFiles=true];
189248
}
190249

191250
// ---- rascal-language-server ------------------------------------------------
192251

193-
public PathConfig getLSPPathConfig() {
194-
return makePathConfig([ REPO + "rascal-lsp/src/main/rascal", REPO + "rascal-lsp/src/test/rascal"],
195-
[ RASCAL_JAR ]);
252+
public PathConfig getLSPPathConfig(bool compiler = false) {
253+
return makePathConfig(RASCAL_LSP,
254+
[ RASCAL_LSP + "src/main/rascal", RASCAL_LSP + "src/test/rascal"],
255+
[ RASCAL ],
256+
compiler=compiler);
196257
}
197258

198-
public RascalCompilerConfig getLSPCompilerConfig(){
199-
return rascalCompilerConfig(getLSPPathConfig())[verbose = true][logWrittenFiles=true];
259+
public RascalCompilerConfig getLSPCompilerConfig(bool compiler = true){
260+
return rascalCompilerConfig(getLSPPathConfig(compiler=compiler))[verbose = true][logWrittenFiles=true];
200261
}
201262

202263
// ---- php-analysis -----------------------------------------------------------
203264

204-
public PathConfig getPHPPathConfig() {
205-
return makePathConfig([ REPO + "php-analysis/src/main/rascal", REPO + "php-analysis/src/test/rascal"],
206-
[ RASCAL_JAR ]);
265+
public PathConfig getPHPPathConfig(bool compiler = false) {
266+
return makePathConfig(PHP_ANALYSIS,
267+
[ PHP_ANALYSIS + "src/main/rascal", PHP_ANALYSIS + "src/test/rascal"],
268+
[ RASCAL ],
269+
compiler=compiler);
207270
}
208271

209-
public RascalCompilerConfig getPHPCompilerConfig(){
210-
return rascalCompilerConfig(getPHPPathConfig())[verbose = true][logWrittenFiles=true];
272+
public RascalCompilerConfig getPHPCompilerConfig(bool compiler = true){
273+
return rascalCompilerConfig(getPHPPathConfig(compiler=compiler))[verbose = true][logWrittenFiles=true];
211274
}
212275

213276
// ---- VSCode-----------------------------------------------------------------
@@ -247,10 +310,12 @@ public RascalCompilerConfig getVSCodeCompilerConfig(){
247310
// ---- Outdated TypePal Usage -----------------------------------------------------------------
248311

249312
public PathConfig getOutdatedTPLPathConfig() {
250-
return makePathConfig([REPO + "rascal-core/src/org/rascalmpl/core/library"],
251-
[ RASCAL_JAR, OUTDATED_TYPEPAL_JAR ]);
313+
return makePathConfig(RASCAL_CORE,
314+
[RASCAL_CORE + "src/org/rascalmpl/core/library"],
315+
[ RASCAL, OUTDATED_TYPEPAL ],
316+
compiler=compiler);
252317
}
253318

254-
public RascalCompilerConfig getOutdatedTPLCompilerConfig(){
255-
return rascalCompilerConfig(getOutdatedTPLPathConfig())[verbose = true][logWrittenFiles=true];
319+
public RascalCompilerConfig getOutdatedTPLCompilerConfig(bool compier = true){
320+
return rascalCompilerConfig(getOutdatedTPLPathConfig(compiler=compiler))[verbose = true][logWrittenFiles=true];
256321
}

src/org/rascalmpl/core/library/lang/rascalcore/check/tests/BinaryDependencyTests.rsc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ test bool importSimpleSourceModuleWithRascalAsLib(){
183183
' return 0;
184184
'}"),
185185
createPathConfig(clientName)
186-
[libs=[rascalPCFG.resources]]
186+
[libs=[rascalPCFG.bin]]
187187
[srcs=[src(clientName), src(libName)]]
188188
);
189189
return checkExpectNoErrors("LibCall", client.pcfg, remove = [lib, client]);
@@ -388,8 +388,8 @@ AGrammar getGrammar(TModel tm){
388388
// The binary compatibility test for TModels
389389
390390
bool binaryCompatible(tuple[TModel old, TModel new] tms){
391-
iprintln(domain(tms.old.logical2physical));
392-
iprintln(domain(tms.new.logical2physical));
391+
if(verbose) iprintln(domain(tms.old.logical2physical));
392+
if(verbose) iprintln(domain(tms.new.logical2physical));
393393
return getGrammar(tms.old) == getGrammar(tms.new)
394394
&& domain(tms.old.logical2physical) <= domain(tms.new.logical2physical);
395395
}

0 commit comments

Comments
 (0)