Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
9 changes: 9 additions & 0 deletions test/mason/mason-build/SwitchTypes/Mason.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[brick]
name="SwitchTypes"
version="0.1.0"
chplVersion="2.8.0"
license="None"
type="application"

[dependencies]

23 changes: 23 additions & 0 deletions test/mason/mason-build/SwitchTypes/src/SwitchTypes.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* Documentation for SwitchTypes */
module SwitchTypes {

record myRec {
var x: string;
var y: string;
}
class MyClass {
var x: string;
var y: string;
}
config type myType;
config param myString1: string;
config const myString2: string;

proc main() {
var t = new myType(myString1, myString2);
writeln(t.type:string, " ", t);
if isUnmanagedClass(t) {
delete t;
}
}
}
49 changes: 49 additions & 0 deletions test/mason/mason-build/configArgs.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
+ cd SwitchTypes
+ mason build -- -smyType=myRec '-smyString1='\''hello world'\'''
Compiling [debug] target: SwitchTypes
Build Successful

+ mason run -- '--myString2='\''goodbye world'\'''
myRec (x = hello world, y = 'goodbye world')
+ mason build -- --set myType=myRec --set 'myString1='\''hello world'\'''
Compiling [debug] target: SwitchTypes
Build Successful

+ mason run -- '--myString2='\''goodbye world'\'''
myRec (x = hello world, y = 'goodbye world')
+ mason build -- '-smyType=owned MyClass' '-smyString1='\''hello world'\'''
Compiling [debug] target: SwitchTypes
Build Successful

+ mason run -- '--myString2='\''goodbye world'\'''
owned MyClass {x = hello world, y = 'goodbye world'}
+ mason build -- --set 'myType=owned MyClass' --set 'myString1='\''hello world'\'''
Compiling [debug] target: SwitchTypes
Build Successful

+ mason run -- '--myString2='\''goodbye world'\'''
owned MyClass {x = hello world, y = 'goodbye world'}
+ mason build -- '-smyType=shared MyClass?' '-smyString1='\''hello world'\'''
Compiling [debug] target: SwitchTypes
Build Successful

+ mason run -- '--myString2='\''goodbye world'\'''
shared MyClass? {x = hello world, y = 'goodbye world'}
+ mason build -- --set 'myType=shared MyClass?' --set 'myString1='\''hello world'\'''
Compiling [debug] target: SwitchTypes
Build Successful

+ mason run -- '--myString2='\''goodbye world'\'''
shared MyClass? {x = hello world, y = 'goodbye world'}
+ mason build -- '-smyType=unmanaged MyClass' '-smyString1='\''hello world'\'''
Compiling [debug] target: SwitchTypes
Build Successful

+ mason run -- '--myString2='\''goodbye world'\'''
unmanaged MyClass {x = hello world, y = 'goodbye world'}
+ mason build -- --set 'myType=unmanaged MyClass' --set 'myString1='\''hello world'\'''
Compiling [debug] target: SwitchTypes
Build Successful

+ mason run -- '--myString2='\''goodbye world'\'''
unmanaged MyClass {x = hello world, y = 'goodbye world'}
25 changes: 25 additions & 0 deletions test/mason/mason-build/configArgs.masontest
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cd SwitchTypes

# test records
mason build -- -smyType=myRec -smyString1="'hello world'"
mason run -- --myString2="'goodbye world'"
mason build -- --set myType=myRec --set myString1="'hello world'"
mason run -- --myString2="'goodbye world'"

# test owned classes
mason build -- -smyType='owned MyClass' -smyString1="'hello world'"
mason run -- --myString2="'goodbye world'"
mason build -- --set myType='owned MyClass' --set myString1="'hello world'"
mason run -- --myString2="'goodbye world'"

# test shared classes
mason build -- -smyType='shared MyClass?' -smyString1="'hello world'"
mason run -- --myString2="'goodbye world'"
mason build -- --set myType='shared MyClass?' --set myString1="'hello world'"
mason run -- --myString2="'goodbye world'"

# test unmanaged classes
mason build -- -smyType='unmanaged MyClass' -smyString1="'hello world'"
mason run -- --myString2="'goodbye world'"
mason build -- --set myType='unmanaged MyClass' --set myString1="'hello world'"
mason run -- --myString2="'goodbye world'"
19 changes: 19 additions & 0 deletions test/mason/mason-build/rebuildOnFailure.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
+ cd CompflagsBug
+ mason build
Compiling [debug] target: CompflagsBug
Build Successful

+ mason build -- -sUnknownFlag=1
Build Failed
Compiling [debug] target: CompflagsBug
error: Trying to set unrecognized config 'UnknownFlag' via -s flag
+ true
+ mason build -- -sUnknownFlag=1
Build Failed
Compiling [debug] target: CompflagsBug
error: Trying to set unrecognized config 'UnknownFlag' via -s flag
+ true
+ mason build
Compiling [debug] target: CompflagsBug
Build Successful

7 changes: 7 additions & 0 deletions test/mason/mason-build/rebuildOnFailure.masontest
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cd CompflagsBug

mason build
# make sure we get an error each time
mason build -- -sUnknownFlag=1 || true
mason build -- -sUnknownFlag=1 || true
mason build
18 changes: 15 additions & 3 deletions tools/mason/MasonBuild.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use Subprocess;
use TOML;

import Path;
import FileSystem;
import MasonPrereqs;

private var log = new logger("mason build");
Expand Down Expand Up @@ -161,6 +162,7 @@ proc buildProgram(release: bool, show: bool, force: bool, skipUpdate: bool,
projectHome, sourceList, gitList) {
writeln("Build Successful\n");
} else {
invalidateFingerprint(projectName, fingerprintDir);
throw new MasonError("Build Failed");
}
} else {
Expand Down Expand Up @@ -196,7 +198,8 @@ proc compileSrc(lockFile: borrowed Toml, binLoc: string,
var cmd: list(string);
cmd.pushBack("chpl");
cmd.pushBack(pathToProj);
cmd.pushBack("-o " + moveTo);
cmd.pushBack("-o");
cmd.pushBack(moveTo);

cmd.pushBack(compopts);

Expand Down Expand Up @@ -247,8 +250,8 @@ proc compileSrc(lockFile: borrowed Toml, binLoc: string,
if release then "release" else "debug", project);

// compile Program with deps
const command = " ".join(cmd.these());
log.debugln("Compilation command: " + command);
const command = cmd.toArray();
log.debugln("Compilation command: " + " ".join(command));
var compilation = runWithStatus(command);
if compilation != 0 {
return false;
Expand Down Expand Up @@ -519,3 +522,12 @@ proc checkFingerprint(projectName:string,
}
}
}

proc invalidateFingerprint(projectName:string, fingerprintDir: string) {
const fingerprintFile = joinPath(fingerprintDir,
"%s-%s".format(projectName, "fingerprint"));
log.debugf("Invalidating fingerprint '%s'\n", fingerprintFile);
if isFile(fingerprintFile) {
FileSystem.remove(fingerprintFile);
}
}
3 changes: 3 additions & 0 deletions tools/mason/MasonExample.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ proc runExamples(show: bool, run: bool, build: bool, release: bool,
const compilation = runWithStatus(compCommand.toArray());

if compilation != 0 {
const fingerprintDir =
joinPath(projectHome, "target", "example", ".fingerprint");
invalidateFingerprint(projectName, fingerprintDir);
stderr.writeln("compilation failed for " + example);
} else {
if show || !run then
Expand Down
2 changes: 1 addition & 1 deletion tools/mason/MasonPrereqs.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ iter prereqs(const baseDir = here.cwd()) {
"but it looks to be a file. It will be ignored.", prereqsDir);
}
} else {
log.debugf("%s doesn't exist.\n", prereqsDir);
log.debugf("%s don't exist.\n", prereqsDir);
}
}