         }
     }
     
-    func testUnresolvablePCFile() {
-        loadPCFile("failure_case.pc") { parser in
-            if parser != nil {
-                XCTFail("parsing should have failed: \(parser.debugDescription)")
-            }
+    func testUnresolvablePCFile() throws {
+        do {
+            try loadPCFile("failure_case.pc")
+            XCTFail("Unexpected success")
+        } catch PkgConfigError.parsingError(let desc) {
+            XCTAssert(desc.hasPrefix("Expected variable in"))
         }
     }
     
     func testEscapedSpaces() {
-        loadPCFile("escaped_spaces.pc") { parser in
-            guard let parser = parser else { XCTFail("Unexpected parsing error"); return}
+        try! loadPCFile("escaped_spaces.pc") { parser in
             XCTAssertEqual(parser.variables, ["prefix": "/usr/local/bin", "exec_prefix": "/usr/local/bin", "my_dep": "atk"])
             XCTAssertEqual(parser.dependencies, ["gdk-3.0", "atk"])
             XCTAssertEqual(parser.cFlags, ["-I/usr/local/Wine Cellar/gtk+3/3.18.9/include/gtk-3.0", "-I/after/extra/spaces"])

    }
    
    func testEmptyCFlags() {
        loadPCFile("empty_cflags.pc") { parser in
            guard let parser = parser else { XCTFail("Unexpected parsing error"); return}
            XCTAssertEqual(parser.variables, ["prefix": "/usr/local/bin", "exec_prefix": "/usr/local/bin"])
            XCTAssertEqual(parser.dependencies, ["gdk-3.0", "atk"])
            XCTAssertEqual(parser.cFlags, [])

final class PkgConfigParserTests: XCTestCase {
    
    func testGTK3PCFile() {
        try! loadPCFile("gtk+-3.0.pc") { parser in
            XCTAssertEqual(parser.variables, ["libdir": "/usr/local/Cellar/gtk+3/3.18.9/lib", "gtk_host": "x86_64-apple-darwin15.3.0", "includedir": "/usr/local/Cellar/gtk+3/3.18.9/include", "prefix": "/usr/local/Cellar/gtk+3/3.18.9", "gtk_binary_version": "3.0.0", "exec_prefix": "/usr/local/Cellar/gtk+3/3.18.9", "targets": "quartz"])
            XCTAssertEqual(parser.dependencies, ["gdk-3.0", "atk", "cairo", "cairo-gobject", "gdk-pixbuf-2.0", "gio-2.0"])
            XCTAssertEqual(parser.cFlags, ["-I/usr/local/Cellar/gtk+3/3.18.9/include/gtk-3.0"])
