diff --git a/test/mason/mason-build/SwitchTypes.notest b/test/mason/mason-build/SwitchTypes.notest new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/mason/mason-build/SwitchTypes/Mason.toml b/test/mason/mason-build/SwitchTypes/Mason.toml new file mode 100644 index 000000000000..8669c88077c7 --- /dev/null +++ b/test/mason/mason-build/SwitchTypes/Mason.toml @@ -0,0 +1,9 @@ +[brick] +name="SwitchTypes" +version="0.1.0" +chplVersion="2.8.0" +license="None" +type="application" + +[dependencies] + diff --git a/test/mason/mason-build/SwitchTypes/src/SwitchTypes.chpl b/test/mason/mason-build/SwitchTypes/src/SwitchTypes.chpl new file mode 100644 index 000000000000..23e442153ea1 --- /dev/null +++ b/test/mason/mason-build/SwitchTypes/src/SwitchTypes.chpl @@ -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; + } + } +} diff --git a/test/mason/mason-build/configArgs.good b/test/mason/mason-build/configArgs.good new file mode 100644 index 000000000000..67d581b8aea8 --- /dev/null +++ b/test/mason/mason-build/configArgs.good @@ -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'} diff --git a/test/mason/mason-build/configArgs.masontest b/test/mason/mason-build/configArgs.masontest new file mode 100644 index 000000000000..984c8800aadb --- /dev/null +++ b/test/mason/mason-build/configArgs.masontest @@ -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'" diff --git a/test/mason/mason-build/rebuildOnFailure.good b/test/mason/mason-build/rebuildOnFailure.good new file mode 100644 index 000000000000..246c19283dac --- /dev/null +++ b/test/mason/mason-build/rebuildOnFailure.good @@ -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 + diff --git a/test/mason/mason-build/rebuildOnFailure.masontest b/test/mason/mason-build/rebuildOnFailure.masontest new file mode 100644 index 000000000000..4f390a6cc6b9 --- /dev/null +++ b/test/mason/mason-build/rebuildOnFailure.masontest @@ -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 diff --git a/tools/mason/MasonBuild.chpl b/tools/mason/MasonBuild.chpl index 7d4637b904f2..594a5e2b888d 100644 --- a/tools/mason/MasonBuild.chpl +++ b/tools/mason/MasonBuild.chpl @@ -35,6 +35,7 @@ use Subprocess; use TOML; import Path; +import FileSystem; import MasonPrereqs; private var log = new logger("mason build"); @@ -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 { @@ -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); @@ -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; @@ -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); + } +} diff --git a/tools/mason/MasonExample.chpl b/tools/mason/MasonExample.chpl index 07e6b0b2430c..09bed1b067a8 100644 --- a/tools/mason/MasonExample.chpl +++ b/tools/mason/MasonExample.chpl @@ -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 diff --git a/tools/mason/MasonPrereqs.chpl b/tools/mason/MasonPrereqs.chpl index c5040ff9b9f3..0558537d423d 100644 --- a/tools/mason/MasonPrereqs.chpl +++ b/tools/mason/MasonPrereqs.chpl @@ -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); } }