[swift-users] Debugging XCTests on Linux

Robert Atkins ratkins+swift-users at fastmail.fm
Fri Jan 6 03:41:48 CST 2017


On Thu, 5 Jan 2017, at 18:13, Ankit Agarwal wrote:

> Using swift module in REPL:



[...]



> $ swift build

> $ swift -I .build/debug -L .build/debug -lResult -I
> /usr/lib/clang/3.8/include
> Welcome to Swift version 3.1-dev (LLVM 217eb6c2b6, Clang 34a98ce92e,
> Swift 1eb5648c46). Type :help for assistance.
>   1> import Result

>   2> let a = Result<String, AnyError>("a")

> a: Result.Result<String, Result.AnyError> = success {

>   success = "a"

> }



Oh wait, this works for me! It was the specific thing I was trying to
do (wrapping an NSError instance in an AnyError) that breaks  which
was leading me to think importing the Result library into the REPL
wasn't working:


$ swift -I.build/debug -L.build/debug -lResult
Welcome to Swift version 3.0.2 (swift-3.0.2-RELEASE). Type :help for
assistance.
  1> import Foundation

  2> import Result

  3> let r = Result<String, AnyError>("a")

r: Result.Result<String, Result.AnyError> = success {

  success = "a"

}

  4> let nse = NSError(domain: "Foo", code: 42, userInfo: nil)

nse: Foundation.NSError = {

  Foundation.NSObject = {}

  _domain = "Foo"

  _code = 42

  _userInfo = nil

}

  5> let ae = AnyError(nse)

ae: Result.AnyError = {

  error = <extracting data from value failed>



}

Execution interrupted. Enter code to recover and continue.

Enter LLDB commands to investigate (type :help for assistance.)

  6>  



So it looks like I have a Foundation on Linux bug? I will do what the
REPL suggests and see if I can figure out what's going on.


Thanks, Robert.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170106/2f25913c/attachment.html>


More information about the swift-users mailing list