Commit 93f0508f authored by Drew's avatar Drew

Overlay on a vector that doesn't exist

(the old value is the empty vector)
parent 9edddb6c
......@@ -79,8 +79,13 @@ final public class Task {
for (optionName, optionValue) in overlay {
switch(optionValue) {
case ParseValue.Vector(let vectorValue):
guard let existingValue = self[optionName]?.vector else {
fatalError("Can't overlay on \(self.key)[\(optionName)]")
let existingValue: [ParseValue]
if let ev = self[optionName]?.vector {
existingValue = ev
}
else {
existingValue = []
}
guard let optionValueVec = optionValue.vector else {
......
......@@ -104,6 +104,15 @@ class PackageTests: Test {
guard let stringOption = package5.tasks["build"]?["stringOption"]?.string else {
fatalError("no string option?")
}
try test.assert(stringOption == "stringOption")
guard let package6 = Package(filepath: filepath, overlay: ["emptyVecOption"]) else { print("error"); try test.assert(false); return }
guard let vecOption = package6.tasks["build"]?["emptyVecOption"]?.vector else {
fatalError("no vec option?")
}
try test.assert(vecOption.count == 1)
try test.assert(vecOption[0].string == "OVERLAY")
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment