问:
React Native finishes in timeout on splash screen while detox test
Description

I have problem with timeout and I don't know why. It asks for permissions and then it set the permissions (probably). In this moment app looks loaded, but after that there will show black screen with spinner for a moment and then splash screen. In this moment the app is stuck.

I found few issues about timeout, but I tried a lot wrote there but nothing worked. My colleague tried to run Detox on the same project with the same package versions and it was without problem.Hhe had the same versions of React Native, XCode, Node, Mocha and Detox.

What I tried:

Few versions of Node: 8.1.3, 8.9.1 and 9.1.0

Reinstall Node

Delete and install node_modules again (yarn/npm)

Change Detox versions: 5.9.4 and 5.8.1

Change Mocha versions: 4.0.1 and 3.5.2

Delete and install App in ios simulator

upgrade XCode (9.0.1 –> 9.1)

Recreate detox builds,

Delete npm cache

Delete detox cache

Test:

```<code>describe('Permissions', () => {
  beforeEach(async () => {
    await device.launchApp({permissions: {
      notifications: 'YES',
      location: 'always',
    }});
    await device.reloadReactNative()
  });

  it('should have welcome screen', async () => {
    await element(by.id('searchCarsButton')).tap()
  })
})
</code>```

Detox, Node, Device, Xcode and macOS Versions

Detox: 5.9.4, 5.8.1

Node: 8.1.3

Device: ios simulator

Xcode: 9.1

macOS: Sierra

React Native: 0.44.0

Device and verbose Detox logs

```$ detox test --loglevel verbose
node_modules/.bin/mocha e2e --opts e2e/mocha.opts  --loglevel verbose

detox-server info 14:33:10: server listening on localhost:50396...
detox verb ws onOpen [object Object]
detox verb ws send: {"type":"login","params":{"sessionId":"c14ee5fe-de13-5f60-b61f-ff487043587b","role":"tester"},"messageId":0}
detox verb ws onMessage: {"type":"loginSuccess","params":{"sessionId":"c14ee5fe-de13-5f60-b61f-ff487043587b","role":"tester"},"messageId":0}
detox verb ws
detox verb 1: applesimutils --list "iPhone 7" --maxResults=1
detox info 1: Searching for device matching iPhone 7...
detox verb 1: stdout: [
detox verb 1: stdout:   {
detox verb 1: stdout:     "state" : "Booted",
detox verb 1: stdout:     "availability" : "(available)",
detox verb 1: stdout:     "name" : "iPhone 7",
detox verb 1: stdout:     "udid" : "2EE82BFA-2351-4627-937C-B93904827F29",
detox verb 1: stdout:     "os" : {
detox verb 1: stdout:       "version" : "11.1",
detox verb 1: stdout:       "availability" : "(available)",
detox verb 1: stdout:       "name" : "iOS 11.1",
detox verb 1: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 1: stdout:       "buildversion" : "15B87"
detox verb 1: stdout:     }
detox verb 1: stdout:   }
detox verb 1: stdout: ]
detox verb 1: stdout:
detox verb 2: applesimutils --list
detox verb 2: stdout: [
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple TV",
detox verb 2: stdout:     "udid" : "2F518141-A525-47B9-9A33-E5AEE34A92FA",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "tvOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.tvOS-11-1",
detox verb 2: stdout:       "buildversion" : "15J580"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple TV 4K",
detox verb 2: stdout:     "udid" : "EA308CF4-5A1F-41EC-AB1C-9E081C6860B4",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "tvOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.tvOS-11-1",
detox verb 2: stdout:       "buildversion" : "15J580"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple TV 4K (at 1080p)",
detox verb 2: stdout:     "udid" : "4A9D24CE-469A-4BA9-86C5-6A6418B906B1",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "tvOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.tvOS-11-1",
detox verb 2: stdout:       "buildversion" : "15J580"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPad (5th generation)",
detox verb 2: stdout:     "udid" : "BDD2070B-24B7-4748-9FCD-1A7A542B1741",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPad Air",
detox verb 2: stdout:     "udid" : "EE452C63-A1CB-47A4-9DDE-3C85586C4AB0",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPad Air 2",
detox verb 2: stdout:     "udid" : "8D7EE2CD-A09B-41A9-B7B5-0FEC4634AE1C",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPad Pro (10.5-inch)",
detox verb 2: stdout:     "udid" : "3487A5FF-3C7C-495A-BC8C-2B805908F3AB",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPad Pro (12.9-inch)",
detox verb 2: stdout:     "udid" : "EF72BAC9-BD3B-422A-917B-259E1D4F049D",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPad Pro (12.9-inch) (2nd generation)",
detox verb 2: stdout:     "udid" : "76F7BFE5-981E-4799-A42D-2B2C75CF6B89",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPad Pro (9.7-inch)",
detox verb 2: stdout:     "udid" : "81042BB1-C6D3-4C50-98B6-5DDD226C0A24",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 5s",
detox verb 2: stdout:     "udid" : "DC5CBF57-1804-4FB1-84B1-B47D32371F8D",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 6",
detox verb 2: stdout:     "udid" : "0073B75C-D6DF-4F35-981E-965420C1F660",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 6 Plus",
detox verb 2: stdout:     "udid" : "A8FC2524-4819-49F2-8694-FB03C27C68EE",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 6s",
detox verb 2: stdout:     "udid" : "4B963220-4BD9-4389-AB2D-D5B739578F86",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 6s Plus",
detox verb 2: stdout:     "udid" : "4973CA12-2A69-42ED-A2C2-42AAB9FB2DB7",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Booted",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 7",
detox verb 2: stdout:     "udid" : "2EE82BFA-2351-4627-937C-B93904827F29",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 7 Plus",
detox verb 2: stdout:     "udid" : "9D7D03DD-10CE-4529-A356-62479A5A6C6A",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 8",
detox verb 2: stdout:     "udid" : "4C3124D0-5353-4471-BB7B-9D9FB30298A7",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 8 Plus",
detox verb 2: stdout:     "udid" : "D5350B7C-B7F9-4F36-B2F4-6D97D63C4869",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone SE",
detox verb 2: stdout:     "udid" : "6EA12F63-932D-456B-B74F-68732DC65EFE",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone X",
detox verb 2: stdout:     "udid" : "30AB0A5F-1E84-4747-AC74-882A0823177F",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple Watch - 38mm",
detox verb 2: stdout:     "udid" : "E0A4995F-4B50-4E6A-B13C-FC8863F4A677",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "4.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "watchOS 4.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-4-1",
detox verb 2: stdout:       "buildversion" : "15R844"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple Watch - 42mm",
detox verb 2: stdout:     "udid" : "4CD40B3E-A994-4852-9058-22EAC2B26882",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "4.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "watchOS 4.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-4-1",
detox verb 2: stdout:       "buildversion" : "15R844"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple Watch Series 2 - 38mm",
detox verb 2: stdout:     "udid" : "F9A49912-44A6-40EF-AC72-224E05461CF2",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "4.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "watchOS 4.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-4-1",
detox verb 2: stdout:       "buildversion" : "15R844"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple Watch Series 2 - 42mm",
detox verb 2: stdout:     "udid" : "F23C9051-AF9B-401E-8DEC-B19BA31C7C0E",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "4.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "watchOS 4.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-4-1",
detox verb 2: stdout:       "buildversion" : "15R844"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple Watch Series 3 - 38mm",
detox verb 2: stdout:     "udid" : "16D30FC1-9D10-462B-B28C-1DC54D6D78D0",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "4.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "watchOS 4.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-4-1",
detox verb 2: stdout:       "buildversion" : "15R844"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple Watch Series 3 - 42mm",
detox verb 2: stdout:     "udid" : "FE83E863-043D-4BB8-8C6F-3E0D5C39DD18",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "4.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "watchOS 4.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-4-1",
detox verb 2: stdout:       "buildversion" : "15R844"
detox verb 2: stdout:     }
detox verb 2: stdout:   }
detox verb 2: stdout: ]
detox verb 2: stdout:
detox verb 3: /usr/bin/xcrun simctl uninstall 2EE82BFA-2351-4627-937C-B93904827F29 com.creativedock.hoppycar
detox info 3: Uninstalling com.creativedock.hoppycar...
detox info 3: com.creativedock.hoppycar uninstalled
detox verb 4: /usr/bin/xcrun simctl install 2EE82BFA-2351-4627-937C-B93904827F29 /Applications/MAMP/htdocs/droover/ios/build/Build/Products/Debug-iphonesimulator/hoppycar.app
detox info 4: Installing /Applications/MAMP/htdocs/droover/ios/build/Build/Products/Debug-iphonesimulator/hoppycar.app...
detox info 4: /Applications/MAMP/htdocs/droover/ios/build/Build/Products/Debug-iphonesimulator/hoppycar.app installed
detox verb 5: /usr/bin/xcrun simctl terminate 2EE82BFA-2351-4627-937C-B93904827F29 com.creativedock.hoppycar
detox info 5: Terminating com.creativedock.hoppycar...
detox info 5: com.creativedock.hoppycar terminated
detox verb 6: /bin/cat /dev/null >$HOME/Library/Developer/CoreSimulator/Devices/2EE82BFA-2351-4627-937C-B93904827F29/data/tmp/detox.last_launch_app_log.out 2>$HOME/Library/Developer/CoreSimulator/Devices/2EE82BFA-2351-4627-937C-B93904827F29/data/tmp/detox.last_launch_app_log.err && SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="/Users/janvaclavik/Library/Detox/ios/dcbded2050005ff99b0bffc826182a2fb35fa7a4/Detox.framework/Detox" /usr/bin/xcrun simctl launch --stdout=/tmp/detox.last_launch_app_log.out --stderr=/tmp/detox.last_launch_app_log.err 2EE82BFA-2351-4627-937C-B93904827F29 com.creativedock.hoppycar --args -detoxServer ws://localhost:50396 -detoxSessionId c14ee5fe-de13-5f60-b61f-ff487043587b
detox info 6: Launching com.creativedock.hoppycar...
detox verb 6: stdout: com.creativedock.hoppycar: 28279
detox verb 6: stdout:
detox info 6: com.creativedock.hoppycar launched. The stdout and stderr logs were recreated, you can watch them with:
        tail -F $HOME/Library/Developer/CoreSimulator/Devices/2EE82BFA-2351-4627-937C-B93904827F29/data/tmp/detox.last_launch_app_log.{out,err}
detox verb ws send: {"type":"isReady","params":{},"messageId":-1000}
detox verb ws onMessage: {"type":"ready","messageId":-1000,"params":{}}
detox verb ws
  Permissions
detox verb 7: applesimutils --simulator 2EE82BFA-2351-4627-937C-B93904827F29 --bundle com.creativedock.hoppycar --setPermissions notifications=YES,location=always
detox info 7: Trying to set permissions...
detox info 7: Permissions are set
detox verb 8: /bin/cat /dev/null >$HOME/Library/Developer/CoreSimulator/Devices/2EE82BFA-2351-4627-937C-B93904827F29/data/tmp/detox.last_launch_app_log.out 2>$HOME/Library/Developer/CoreSimulator/Devices/2EE82BFA-2351-4627-937C-B93904827F29/data/tmp/detox.last_launch_app_log.err && SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="/Users/janvaclavik/Library/Detox/ios/dcbded2050005ff99b0bffc826182a2fb35fa7a4/Detox.framework/Detox" /usr/bin/xcrun simctl launch --stdout=/tmp/detox.last_launch_app_log.out --stderr=/tmp/detox.last_launch_app_log.err 2EE82BFA-2351-4627-937C-B93904827F29 com.creativedock.hoppycar --args -detoxServer ws://localhost:50396 -detoxSessionId c14ee5fe-de13-5f60-b61f-ff487043587b
detox info 8: Launching com.creativedock.hoppycar...
detox verb 8: stdout: com.creativedock.hoppycar: 28306
detox verb 8: stdout:
detox info 8: com.creativedock.hoppycar launched. The stdout and stderr logs were recreated, you can watch them with:
        tail -F $HOME/Library/Developer/CoreSimulator/Devices/2EE82BFA-2351-4627-937C-B93904827F29/data/tmp/detox.last_launch_app_log.{out,err}
detox verb ws send: {"type":"isReady","params":{},"messageId":-1000}
detox verb ws onMessage: {"type":"ready","messageId":-1000,"params":{}}
detox verb ws
detox verb ws send: {"type":"reactNativeReload","params":{},"messageId":-1000}
detox verb ws onMessage: {"type":"ready","messageId":-1000,"params":{}}
detox verb ws
detox verb ws send: {"type":"invoke","params":{"target":{"type":"Invocation","value":{"target":{"type":"EarlGrey","value":"instance"},"method":"detox_selectElementWithMatcher:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"matcherForAccessibilityID:","args":[{"type":"NSString","value":"searchCarsButton"}]}}]}},"method":"performAction:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYActions"},"method":"actionForTap","args":[]}}]},"messageId":1}
    1) should have welcome screen

detox verb ws send: {"type":"cleanup","params":{"stopRunner":true},"messageId":2}
detox verb ws onMessage: {"type":"cleanupDone","messageId":2,"params":{}}
detox verb ws

  0 passing (3m)
  1 failing

  1) Permissions should have welcome screen:
     Error: Timeout of 135000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

child_process.js:631
    throw err;
    ^

Error: Command failed: node_modules/.bin/mocha e2e --opts e2e/mocha.opts  --loglevel verbose
    at checkExecSyncError (child_process.js:588:13)
    at Object.execSync (child_process.js:628:13)
    at runMocha (/usr/local/lib/node_modules/detox/local-cli/detox-test.js:56:6)
    at Object.<anonymous> (/usr/local/lib/node_modules/detox/local-cli/detox-test.js:36:5)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
```

<p><strong>detox.last_launch_app_log.{out,err}:</strong></p>

```...
2017-11-13 12:20:55.393 dr[26453:980543] ☣ DETOX:: Ignoring timer: 35 failure reason: "duration>1.5"
2017-11-13 12:20:57.402 dr[26453:980543] ☣ DETOX:: Ignoring timer: 36 failure reason: "duration>1.5"
2017-11-13 12:20:59.410 dr[26453:980543] ☣ DETOX:: Ignoring timer: 37 failure reason: "duration>1.5"
...
```

答:
The error is actually giving you the problem. "For async tests and hooks, ensure "done()" is called;"

I believe your issue is that you are turning the functions into promises with the async and the test framework does not know when thet are done.

Remove your async/await and just use a normal .then() and when finished, call the done() function. That should end the test.

More info here: https://mochajs.org/#asynchronous-code

Body:
Description

I have problem with timeout and I don't know why. It asks for permissions and then it set the permissions (probably). In this moment app looks loaded, but after that there will show black screen with spinner for a moment and then splash screen. In this moment the app is stuck.

I found few issues about timeout, but I tried a lot wrote there but nothing worked. My colleague tried to run Detox on the same project with the same package versions and it was without problem.Hhe had the same versions of React Native, XCode, Node, Mocha and Detox.

What I tried:

Few versions of Node: 8.1.3, 8.9.1 and 9.1.0

Reinstall Node

Delete and install node_modules again (yarn/npm)

Change Detox versions: 5.9.4 and 5.8.1

Change Mocha versions: 4.0.1 and 3.5.2

Delete and install App in ios simulator

upgrade XCode (9.0.1 –> 9.1)

Recreate detox builds,

Delete npm cache

Delete detox cache

Test:

describe('Permissions', () => {
  beforeEach(async () => {
    await device.launchApp({permissions: {
      notifications: 'YES',
      location: 'always',
    }});
    await device.reloadReactNative()
  });

  it('should have welcome screen', async () => {
    await element(by.id('searchCarsButton')).tap()
  })
})

Detox, Node, Device, Xcode and macOS Versions

Detox: 5.9.4, 5.8.1

Node: 8.1.3

Device: ios simulator

Xcode: 9.1

macOS: Sierra

React Native: 0.44.0

Device and verbose Detox logs

$ detox test --loglevel verbose
node_modules/.bin/mocha e2e --opts e2e/mocha.opts  --loglevel verbose

detox-server info 14:33:10: server listening on localhost:50396...
detox verb ws onOpen [object Object]
detox verb ws send: {"type":"login","params":{"sessionId":"c14ee5fe-de13-5f60-b61f-ff487043587b","role":"tester"},"messageId":0}
detox verb ws onMessage: {"type":"loginSuccess","params":{"sessionId":"c14ee5fe-de13-5f60-b61f-ff487043587b","role":"tester"},"messageId":0}
detox verb ws
detox verb 1: applesimutils --list "iPhone 7" --maxResults=1
detox info 1: Searching for device matching iPhone 7...
detox verb 1: stdout: [
detox verb 1: stdout:   {
detox verb 1: stdout:     "state" : "Booted",
detox verb 1: stdout:     "availability" : "(available)",
detox verb 1: stdout:     "name" : "iPhone 7",
detox verb 1: stdout:     "udid" : "2EE82BFA-2351-4627-937C-B93904827F29",
detox verb 1: stdout:     "os" : {
detox verb 1: stdout:       "version" : "11.1",
detox verb 1: stdout:       "availability" : "(available)",
detox verb 1: stdout:       "name" : "iOS 11.1",
detox verb 1: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 1: stdout:       "buildversion" : "15B87"
detox verb 1: stdout:     }
detox verb 1: stdout:   }
detox verb 1: stdout: ]
detox verb 1: stdout:
detox verb 2: applesimutils --list
detox verb 2: stdout: [
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple TV",
detox verb 2: stdout:     "udid" : "2F518141-A525-47B9-9A33-E5AEE34A92FA",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "tvOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.tvOS-11-1",
detox verb 2: stdout:       "buildversion" : "15J580"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple TV 4K",
detox verb 2: stdout:     "udid" : "EA308CF4-5A1F-41EC-AB1C-9E081C6860B4",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "tvOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.tvOS-11-1",
detox verb 2: stdout:       "buildversion" : "15J580"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple TV 4K (at 1080p)",
detox verb 2: stdout:     "udid" : "4A9D24CE-469A-4BA9-86C5-6A6418B906B1",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "tvOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.tvOS-11-1",
detox verb 2: stdout:       "buildversion" : "15J580"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPad (5th generation)",
detox verb 2: stdout:     "udid" : "BDD2070B-24B7-4748-9FCD-1A7A542B1741",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPad Air",
detox verb 2: stdout:     "udid" : "EE452C63-A1CB-47A4-9DDE-3C85586C4AB0",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPad Air 2",
detox verb 2: stdout:     "udid" : "8D7EE2CD-A09B-41A9-B7B5-0FEC4634AE1C",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPad Pro (10.5-inch)",
detox verb 2: stdout:     "udid" : "3487A5FF-3C7C-495A-BC8C-2B805908F3AB",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPad Pro (12.9-inch)",
detox verb 2: stdout:     "udid" : "EF72BAC9-BD3B-422A-917B-259E1D4F049D",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPad Pro (12.9-inch) (2nd generation)",
detox verb 2: stdout:     "udid" : "76F7BFE5-981E-4799-A42D-2B2C75CF6B89",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPad Pro (9.7-inch)",
detox verb 2: stdout:     "udid" : "81042BB1-C6D3-4C50-98B6-5DDD226C0A24",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 5s",
detox verb 2: stdout:     "udid" : "DC5CBF57-1804-4FB1-84B1-B47D32371F8D",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 6",
detox verb 2: stdout:     "udid" : "0073B75C-D6DF-4F35-981E-965420C1F660",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 6 Plus",
detox verb 2: stdout:     "udid" : "A8FC2524-4819-49F2-8694-FB03C27C68EE",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 6s",
detox verb 2: stdout:     "udid" : "4B963220-4BD9-4389-AB2D-D5B739578F86",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 6s Plus",
detox verb 2: stdout:     "udid" : "4973CA12-2A69-42ED-A2C2-42AAB9FB2DB7",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Booted",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 7",
detox verb 2: stdout:     "udid" : "2EE82BFA-2351-4627-937C-B93904827F29",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 7 Plus",
detox verb 2: stdout:     "udid" : "9D7D03DD-10CE-4529-A356-62479A5A6C6A",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 8",
detox verb 2: stdout:     "udid" : "4C3124D0-5353-4471-BB7B-9D9FB30298A7",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone 8 Plus",
detox verb 2: stdout:     "udid" : "D5350B7C-B7F9-4F36-B2F4-6D97D63C4869",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone SE",
detox verb 2: stdout:     "udid" : "6EA12F63-932D-456B-B74F-68732DC65EFE",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "iPhone X",
detox verb 2: stdout:     "udid" : "30AB0A5F-1E84-4747-AC74-882A0823177F",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "11.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "iOS 11.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-1",
detox verb 2: stdout:       "buildversion" : "15B87"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple Watch - 38mm",
detox verb 2: stdout:     "udid" : "E0A4995F-4B50-4E6A-B13C-FC8863F4A677",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "4.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "watchOS 4.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-4-1",
detox verb 2: stdout:       "buildversion" : "15R844"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple Watch - 42mm",
detox verb 2: stdout:     "udid" : "4CD40B3E-A994-4852-9058-22EAC2B26882",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "4.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "watchOS 4.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-4-1",
detox verb 2: stdout:       "buildversion" : "15R844"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple Watch Series 2 - 38mm",
detox verb 2: stdout:     "udid" : "F9A49912-44A6-40EF-AC72-224E05461CF2",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "4.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "watchOS 4.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-4-1",
detox verb 2: stdout:       "buildversion" : "15R844"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple Watch Series 2 - 42mm",
detox verb 2: stdout:     "udid" : "F23C9051-AF9B-401E-8DEC-B19BA31C7C0E",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "4.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "watchOS 4.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-4-1",
detox verb 2: stdout:       "buildversion" : "15R844"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple Watch Series 3 - 38mm",
detox verb 2: stdout:     "udid" : "16D30FC1-9D10-462B-B28C-1DC54D6D78D0",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "4.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "watchOS 4.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-4-1",
detox verb 2: stdout:       "buildversion" : "15R844"
detox verb 2: stdout:     }
detox verb 2: stdout:   },
detox verb 2: stdout:   {
detox verb 2: stdout:     "state" : "Shutdown",
detox verb 2: stdout:     "availability" : "(available)",
detox verb 2: stdout:     "name" : "Apple Watch Series 3 - 42mm",
detox verb 2: stdout:     "udid" : "FE83E863-043D-4BB8-8C6F-3E0D5C39DD18",
detox verb 2: stdout:     "os" : {
detox verb 2: stdout:       "version" : "4.1",
detox verb 2: stdout:       "availability" : "(available)",
detox verb 2: stdout:       "name" : "watchOS 4.1",
detox verb 2: stdout:       "identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-4-1",
detox verb 2: stdout:       "buildversion" : "15R844"
detox verb 2: stdout:     }
detox verb 2: stdout:   }
detox verb 2: stdout: ]
detox verb 2: stdout:
detox verb 3: /usr/bin/xcrun simctl uninstall 2EE82BFA-2351-4627-937C-B93904827F29 com.creativedock.hoppycar
detox info 3: Uninstalling com.creativedock.hoppycar...
detox info 3: com.creativedock.hoppycar uninstalled
detox verb 4: /usr/bin/xcrun simctl install 2EE82BFA-2351-4627-937C-B93904827F29 /Applications/MAMP/htdocs/droover/ios/build/Build/Products/Debug-iphonesimulator/hoppycar.app
detox info 4: Installing /Applications/MAMP/htdocs/droover/ios/build/Build/Products/Debug-iphonesimulator/hoppycar.app...
detox info 4: /Applications/MAMP/htdocs/droover/ios/build/Build/Products/Debug-iphonesimulator/hoppycar.app installed
detox verb 5: /usr/bin/xcrun simctl terminate 2EE82BFA-2351-4627-937C-B93904827F29 com.creativedock.hoppycar
detox info 5: Terminating com.creativedock.hoppycar...
detox info 5: com.creativedock.hoppycar terminated
detox verb 6: /bin/cat /dev/null >$HOME/Library/Developer/CoreSimulator/Devices/2EE82BFA-2351-4627-937C-B93904827F29/data/tmp/detox.last_launch_app_log.out 2>$HOME/Library/Developer/CoreSimulator/Devices/2EE82BFA-2351-4627-937C-B93904827F29/data/tmp/detox.last_launch_app_log.err && SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="/Users/janvaclavik/Library/Detox/ios/dcbded2050005ff99b0bffc826182a2fb35fa7a4/Detox.framework/Detox" /usr/bin/xcrun simctl launch --stdout=/tmp/detox.last_launch_app_log.out --stderr=/tmp/detox.last_launch_app_log.err 2EE82BFA-2351-4627-937C-B93904827F29 com.creativedock.hoppycar --args -detoxServer ws://localhost:50396 -detoxSessionId c14ee5fe-de13-5f60-b61f-ff487043587b
detox info 6: Launching com.creativedock.hoppycar...
detox verb 6: stdout: com.creativedock.hoppycar: 28279
detox verb 6: stdout:
detox info 6: com.creativedock.hoppycar launched. The stdout and stderr logs were recreated, you can watch them with:
        tail -F $HOME/Library/Developer/CoreSimulator/Devices/2EE82BFA-2351-4627-937C-B93904827F29/data/tmp/detox.last_launch_app_log.{out,err}
detox verb ws send: {"type":"isReady","params":{},"messageId":-1000}
detox verb ws onMessage: {"type":"ready","messageId":-1000,"params":{}}
detox verb ws
  Permissions
detox verb 7: applesimutils --simulator 2EE82BFA-2351-4627-937C-B93904827F29 --bundle com.creativedock.hoppycar --setPermissions notifications=YES,location=always
detox info 7: Trying to set permissions...
detox info 7: Permissions are set
detox verb 8: /bin/cat /dev/null >$HOME/Library/Developer/CoreSimulator/Devices/2EE82BFA-2351-4627-937C-B93904827F29/data/tmp/detox.last_launch_app_log.out 2>$HOME/Library/Developer/CoreSimulator/Devices/2EE82BFA-2351-4627-937C-B93904827F29/data/tmp/detox.last_launch_app_log.err && SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="/Users/janvaclavik/Library/Detox/ios/dcbded2050005ff99b0bffc826182a2fb35fa7a4/Detox.framework/Detox" /usr/bin/xcrun simctl launch --stdout=/tmp/detox.last_launch_app_log.out --stderr=/tmp/detox.last_launch_app_log.err 2EE82BFA-2351-4627-937C-B93904827F29 com.creativedock.hoppycar --args -detoxServer ws://localhost:50396 -detoxSessionId c14ee5fe-de13-5f60-b61f-ff487043587b
detox info 8: Launching com.creativedock.hoppycar...
detox verb 8: stdout: com.creativedock.hoppycar: 28306
detox verb 8: stdout:
detox info 8: com.creativedock.hoppycar launched. The stdout and stderr logs were recreated, you can watch them with:
        tail -F $HOME/Library/Developer/CoreSimulator/Devices/2EE82BFA-2351-4627-937C-B93904827F29/data/tmp/detox.last_launch_app_log.{out,err}
detox verb ws send: {"type":"isReady","params":{},"messageId":-1000}
detox verb ws onMessage: {"type":"ready","messageId":-1000,"params":{}}
detox verb ws
detox verb ws send: {"type":"reactNativeReload","params":{},"messageId":-1000}
detox verb ws onMessage: {"type":"ready","messageId":-1000,"params":{}}
detox verb ws
detox verb ws send: {"type":"invoke","params":{"target":{"type":"Invocation","value":{"target":{"type":"EarlGrey","value":"instance"},"method":"detox_selectElementWithMatcher:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"matcherForAccessibilityID:","args":[{"type":"NSString","value":"searchCarsButton"}]}}]}},"method":"performAction:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYActions"},"method":"actionForTap","args":[]}}]},"messageId":1}
    1) should have welcome screen

detox verb ws send: {"type":"cleanup","params":{"stopRunner":true},"messageId":2}
detox verb ws onMessage: {"type":"cleanupDone","messageId":2,"params":{}}
detox verb ws

  0 passing (3m)
  1 failing

  1) Permissions should have welcome screen:
     Error: Timeout of 135000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

child_process.js:631
    throw err;
    ^

Error: Command failed: node_modules/.bin/mocha e2e --opts e2e/mocha.opts  --loglevel verbose
    at checkExecSyncError (child_process.js:588:13)
    at Object.execSync (child_process.js:628:13)
    at runMocha (/usr/local/lib/node_modules/detox/local-cli/detox-test.js:56:6)
    at Object.<anonymous> (/usr/local/lib/node_modules/detox/local-cli/detox-test.js:36:5)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)

detox.last_launch_app_log.{out,err}:

...
2017-11-13 12:20:55.393 dr[26453:980543] ☣ DETOX:: Ignoring timer: 35 failure reason: "duration>1.5"
2017-11-13 12:20:57.402 dr[26453:980543] ☣ DETOX:: Ignoring timer: 36 failure reason: "duration>1.5"
2017-11-13 12:20:59.410 dr[26453:980543] ☣ DETOX:: Ignoring timer: 37 failure reason: "duration>1.5"
...


来源: stackexchange

问:
Dynamically allocated pointer to a structure not returning from C function
I am trying to write a concordance program using a linked list in C.  To do this, I am returning a pointer to a dynamically allocated structure from a function.  However, the address of the pointer in the function doesn't match the address of the returned value.  The relevant code is below.

```<code>int main(int argc, char *argv[]){
    ...
    struct wordlist *a = NULL;
    ...
    a = firstNode(word);
    printf("%p\n",(void*)&a);
    ...
}

struct wordlist * firstNode(char *fileWord){
    struct wordlist *newNode = malloc(sizeof *newNode);
    newNode->word = fileWord;
    newNode->next = NULL;
    newNode->previous = NULL;
    printf("%s\n",newNode->word);
    printf("%p\n",(void*)&newNode);
    return newNode;
}
</code>```

When I print the address of newNode, it is always different than when I print the value of a in main.

答:
Are you printing what you return?

No.

You are printing the wrong thing.

```<code> printf("%p\n",newNode);
</code>```

Now you will see the value you return and value you print will match. Previously you were returning on thing and printing another.

Explanation

Earlier you were allocating memory dynamically and the returned value of malloc is stored in local variable newNode. Now you are printing newNode's address. Not what newNode contains which is returned from the function.

Also check the return value of malloc. De-allocate dynamically allocated memory.

ContentLicense: CC BY-SA 3.0

Body:
I am trying to write a concordance program using a linked list in C.  To do this, I am returning a pointer to a dynamically allocated structure from a function.  However, the address of the pointer in the function doesn't match the address of the returned value.  The relevant code is below.

int main(int argc, char *argv[]){
    ...
    struct wordlist *a = NULL;
    ...
    a = firstNode(word);
    printf("%p\n",(void*)&a);
    ...
}

struct wordlist * firstNode(char *fileWord){
    struct wordlist *newNode = malloc(sizeof *newNode);
    newNode->word = fileWord;
    newNode->next = NULL;
    newNode->previous = NULL;
    printf("%s\n",newNode->word);
    printf("%p\n",(void*)&newNode);
    return newNode;
}

When I print the address of newNode, it is always different than when I print the value of a in main.

Body:
Are you printing what you return?

No.

You are printing the wrong thing.

 printf("%p\n",newNode);

Now you will see the value you return and value you print will match. Previously you were returning on thing and printing another.

Explanation

Earlier you were allocating memory dynamically and the returned value of malloc is stored in local variable newNode. Now you are printing newNode's address. Not what newNode contains which is returned from the function.

Also check the return value of malloc. De-allocate dynamically allocated memory.


问:
HP Service Manager RESTful Web Service query
I want to create a web service(in .net) that would get information from HP Service Manager. I know I can use GET in the RESTful API to get the information I need. I just don't know where to start. I've been trough the documentation but since this is my first time doing this I could use some help to get started.

I have been reading the document here on the RESTful API. This is some examples

•/incidents?field1=value1&field2=value2 //Simple
  Query

•/incidents?query=&sort=number:ascending
  //Service Manager Native Query

I have never worked with web service before so it can be hard for me to understand what exactly this means.

答: There is a .net sample under HP SM installation folder.</p>


问:
How can I replace a the pattern ",," with <RETURN> in awk?
I am doing a ldapsearch query which returns the results as follow

```<code>John Joe jjoe@company.com +1 916 662-4727  Ann Tylor Atylor@company.com (987) 654-3210  Steve Harvey sharvey@company.com 4567893210  (321) 956-3344  ...
</code>```

As you can see between each personal record output there is a blank space and the phone numbers might start with +1 or not and might have blank between the numbers or parenthesis and finally between personal records there are two blank spaces. For example:

I would like to transform these entries to the following format:

```<code>John,Joe,jjoe@company.com,(916) 662-4727
Ann,Tylor,Atylor@company.com,(987) 654-3210
Steve,Harvey,sharvey@company.com,(456) 789-3210,(321) 956-3344
...
</code>```

So basically replace the one blanks with one comma "," and two blanks with , so that at the end I have one personal record (comma separated) per line. Example:

I am trying awk and have managed to replace  with "," which makes

```<code><blank><blank> to double comma ",,".
But can't figure out how to turn ",," to <RETURN>
</code>```

11/22/2017      ----******  UPDATE   ******---------           11/22/2017

I made this track too crowded. I will post a fresh questions with more details.

答:
If your Input_file is same as shown sample then following awk may help you in same.

```<code>awk --re-interval '{gsub(/[0-9]{3}-[0-9]{4} +/,"&\n");print}'  Input_file
</code>```

I am having OLD version of awk so I have mentioned --re-interval in it on new awk no need to mention it.

Explanation: Adding explanation for solution too here.

```<code>awk --re-interval '{               ##using --re-interval to use the extended regex as I have old version of awk.
gsub(/[0-9]{3}-[0-9]{4} +/,"&\n"); ##Using gsub utility(global substitute) of awk where I am checking 3 continuous dots then dash(-) then 4 continuous digits and till space with same regex match and NEW LINE.
print                              ##printing the line of Input_file
}'  Input_file                     ##Mentioning the Input_file here.
</code>```

Body:
I am doing a ldapsearch query which returns the results as follow

John Joe jjoe@company.com +1 916 662-4727  Ann Tylor Atylor@company.com (987) 654-3210  Steve Harvey sharvey@company.com 4567893210  (321) 956-3344  ...

As you can see between each personal record output there is a blank space and the phone numbers might start with +1 or not and might have blank between the numbers or parenthesis and finally between personal records there are two blank spaces. For example:

I would like to transform these entries to the following format:

John,Joe,jjoe@company.com,(916) 662-4727
Ann,Tylor,Atylor@company.com,(987) 654-3210
Steve,Harvey,sharvey@company.com,(456) 789-3210,(321) 956-3344
...

So basically replace the one blanks with one comma "," and two blanks with , so that at the end I have one personal record (comma separated) per line. Example:

I am trying awk and have managed to replace  with "," which makes

<blank><blank> to double comma ",,".
But can't figure out how to turn ",," to <RETURN>

11/22/2017      ----******  UPDATE   ******---------           11/22/2017

I made this track too crowded. I will post a fresh questions with more details.

Body:
If your Input_file is same as shown sample then following awk may help you in same.

awk --re-interval '{gsub(/[0-9]{3}-[0-9]{4} +/,"&\n");print}'  Input_file

I am having OLD version of awk so I have mentioned --re-interval in it on new awk no need to mention it.

Explanation: Adding explanation for solution too here.

awk --re-interval '{               ##using --re-interval to use the extended regex as I have old version of awk.
gsub(/[0-9]{3}-[0-9]{4} +/,"&\n"); ##Using gsub utility(global substitute) of awk where I am checking 3 continuous dots then dash(-) then 4 continuous digits and till space with same regex match and NEW LINE.
print                              ##printing the line of Input_file
}'  Input_file                     ##Mentioning the Input_file here.


问:
Shell script diamond
The question is: Using Shell script programming, create a script that asks the user to enter a number and then prints the following shape. The number of rows is double the columns and user input determine the size of the diamond.

```<code>                *
               * *
              * * *
             * * * *
            * * * * *
           * * * * * *
          * * * * * * *
         * * * * * * * *
          * * * * * * *
           * * * * * *
            * * * * *
             * * * *
              * * *
               * *
                *
</code>```

I've been trying this for days. Any help would bee awesome

答:
I've wrote smth like this. 'size' variable is actualy 1/4 of whole diamond. But that's cosmetics, and you should be able to fix it:</p>

```<code>#!/bin/bash

# reading from stdin
read -p 'Size: ' size
# checking if size is a number
echo $size | grep -q -E '^[0-9]+$' || exit 5

vpos=0
while [[ $vpos -le $(( $size * 2 )) ]] ;
do
        hpos=0
        while [[ $hpos -le $(( $size * 2 )) ]] ;
        do

                if [[ $vpos -le $size ]] ;
                then
                        # upper vertical half
                        if ( [ $hpos -lt $(( $size - $vpos )) ] && [ $hpos -lt $size ] ) || ( [ $hpos -gt $(( $size + $vpos )) ] && [ $hpos -gt $size ] )  ;
                        then
                                echo -n ' '
                        else
                                echo -n '*'
                        fi

                else
                        # bottom vertical half
                        if ( [ $hpos -lt $(( $vpos - $size ))  ] && [ $hpos -lt $size ] ) || ( [ $hpos -gt $(( 3 * $size - $vpos )) ] && [ $hpos -gt $size  ] )  ;
                        then
                                echo -n ' '
                        else
                                echo -n '*'
                        fi

                fi

                hpos=$((hpos + 1))

        done ;
        echo ''
        vpos=$((vpos + 1))
done
</code>```

Title: Shell script diamond

Body:
The question is: Using Shell script programming, create a script that asks the user to enter a number and then prints the following shape. The number of rows is double the columns and user input determine the size of the diamond.

                *
               * *
              * * *
             * * * *
            * * * * *
           * * * * * *
          * * * * * * *
         * * * * * * * *
          * * * * * * *
           * * * * * *
            * * * * *
             * * * *
              * * *
               * *
                *

I've been trying this for days. Any help would bee awesome

Body:
I've wrote smth like this. 'size' variable is actualy 1/4 of whole diamond. But that's cosmetics, and you should be able to fix it:

#!/bin/bash

# reading from stdin
read -p 'Size: ' size
# checking if size is a number
echo $size | grep -q -E '^[0-9]+$' || exit 5

vpos=0
while [[ $vpos -le $(( $size * 2 )) ]] ;
do
        hpos=0
        while [[ $hpos -le $(( $size * 2 )) ]] ;
        do

                if [[ $vpos -le $size ]] ;
                then
                        # upper vertical half
                        if ( [ $hpos -lt $(( $size - $vpos )) ] && [ $hpos -lt $size ] ) || ( [ $hpos -gt $(( $size + $vpos )) ] && [ $hpos -gt $size ] )  ;
                        then
                                echo -n ' '
                        else
                                echo -n '*'
                        fi

                else
                        # bottom vertical half
                        if ( [ $hpos -lt $(( $vpos - $size ))  ] && [ $hpos -lt $size ] ) || ( [ $hpos -gt $(( 3 * $size - $vpos )) ] && [ $hpos -gt $size  ] )  ;
                        then
                                echo -n ' '
                        else
                                echo -n '*'
                        fi

                fi

                hpos=$((hpos + 1))

        done ;
        echo ''
        vpos=$((vpos + 1))
done


问:
Sample Cocoa app, ref counting, [pool drain] yields EXC_BAD_ACCESS?
I'm working through Cocoa Programming for Mac OS X (3rd ed) and in chapter 4 I wrote this app:

```<code>int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    //create the date object
    NSCalendarDate *now = [[NSCalendarDate alloc] init];

    //seed random # generator
    srandom(time(NULL));

    NSMutableArray *array;
    array = [[NSMutableArray alloc] init];
    int i;
    for (i=0; i<10; i++){
        //create a date/time that is 'i' weeks from now
        NSCalendarDate *iWeeksFromNow;
        iWeeksFromNow = [now dateByAddingYears:0
                                        months:0
                                          days:(i*7)
                                         hours:0
                                       minutes:0
                                       seconds:0];

        //create a new instance of lottery entry
        LotteryEntry *entry = [[LotteryEntry alloc] init];
        [entry setEntryDate:iWeeksFromNow];

        [array addObject:entry];
        [entry release];
    }
    [now release];
    now = nil;

    for (LotteryEntry *entryToPrint in array) {
        NSLog(@"%@", entryToPrint);
    }
    [array release];
    array = nil;

    NSLog(@"about to drain the pool... (%@)", pool);
    [pool drain];
    NSLog(@"done");
    NSLog(@"GC = %@", [NSGarbageCollector defaultCollector]);
    return 0;
}
</code>```

The LotteryEntry class looks like this:

```<code>@implementation LotteryEntry

- (void)setEntryDate:(NSCalendarDate *)date
{
    entryDate = date;
}

- (NSCalendarDate *)entryDate
{
    return entryDate;
}

- (int)firstNumber
{
    return firstNumber;
}

- (int)secondNumber
{
    return secondNumber;
}

- (id)init
{
    return [self initWithDate:[NSCalendarDate calendarDate]];
}

- (id)initWithDate:(NSCalendarDate *)date
{
    if(![super init])
        return nil;

    NSAssert(date != nil, @"Argument must be non-nil");

    firstNumber = random() % 100 + 1;
    secondNumber = random() % 100 + 1;
    entryDate = [date retain];
    return self;
}

- (NSString *)description
{
    NSString *result;
    result = [[NSString alloc] initWithFormat:@"%@ = %d and %d",
              [entryDate descriptionWithCalendarFormat:@"%b %d %Y"],
              firstNumber,
              secondNumber];
    return result;
}

- (void)dealloc
{
    NSLog(@"deallocating %@", self);
    [entryDate release];
    [super dealloc];
}

@end
</code>```

As you can see I'm retaining and releasing the objects here.  I'm pretty sure my code matches the book's, however when I run the app, at the [pool drain] I get this message:

Program received signal:
  “EXC_BAD_ACCESS”.

I'm not sure what's causing this.  I'm hoping it's something stupid that I missed, but I'd sure appreciate a few other pairs of eyes on it.  Thanks in advance!

(side note:  I'm a .NET developer, so ref counting is pretty foreign to me!)

答:
doh!  Just typing the code made me realize my problem.  Doncha love it when that happens?

I am retaining the date in my init, but I still had that extra setEntryDate method that was not calling retain.  Removing this and calling the initWithDate method instead seemed to fix the problem.

OwnerDisplayName: Ben Scheirman

ContentLicense: CC BY-SA 2.5

Body:
I'm working through Cocoa Programming for Mac OS X (3rd ed) and in chapter 4 I wrote this app:

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    //create the date object
    NSCalendarDate *now = [[NSCalendarDate alloc] init];

    //seed random # generator
    srandom(time(NULL));

    NSMutableArray *array;
    array = [[NSMutableArray alloc] init];
    int i;
    for (i=0; i<10; i++){
        //create a date/time that is 'i' weeks from now
        NSCalendarDate *iWeeksFromNow;
        iWeeksFromNow = [now dateByAddingYears:0
                                        months:0
                                          days:(i*7)
                                         hours:0
                                       minutes:0
                                       seconds:0];

        //create a new instance of lottery entry
        LotteryEntry *entry = [[LotteryEntry alloc] init];
        [entry setEntryDate:iWeeksFromNow];

        [array addObject:entry];
        [entry release];
    }
    [now release];
    now = nil;

    for (LotteryEntry *entryToPrint in array) {
        NSLog(@"%@", entryToPrint);
    }
    [array release];
    array = nil;

    NSLog(@"about to drain the pool... (%@)", pool);
    [pool drain];
    NSLog(@"done");
    NSLog(@"GC = %@", [NSGarbageCollector defaultCollector]);
    return 0;
}

The LotteryEntry class looks like this:

@implementation LotteryEntry

- (void)setEntryDate:(NSCalendarDate *)date
{
    entryDate = date;
}

- (NSCalendarDate *)entryDate
{
    return entryDate;
}

- (int)firstNumber
{
    return firstNumber;
}

- (int)secondNumber
{
    return secondNumber;
}

- (id)init
{
    return [self initWithDate:[NSCalendarDate calendarDate]];
}

- (id)initWithDate:(NSCalendarDate *)date
{
    if(![super init])
        return nil;

    NSAssert(date != nil, @"Argument must be non-nil");

    firstNumber = random() % 100 + 1;
    secondNumber = random() % 100 + 1;
    entryDate = [date retain];
    return self;
}

- (NSString *)description
{
    NSString *result;
    result = [[NSString alloc] initWithFormat:@"%@ = %d and %d",
              [entryDate descriptionWithCalendarFormat:@"%b %d %Y"],
              firstNumber,
              secondNumber];
    return result;
}

- (void)dealloc
{
    NSLog(@"deallocating %@", self);
    [entryDate release];
    [super dealloc];
}

@end

As you can see I'm retaining and releasing the objects here.  I'm pretty sure my code matches the book's, however when I run the app, at the [pool drain] I get this message:

Program received signal:
  “EXC_BAD_ACCESS”.

I'm not sure what's causing this.  I'm hoping it's something stupid that I missed, but I'd sure appreciate a few other pairs of eyes on it.  Thanks in advance!

(side note:  I'm a .NET developer, so ref counting is pretty foreign to me!)


问:
How can I schedule an email to be sent at some point in the future in django?
I want to schedule an email to be sent to a user upon a specific action.
However, if the user takes another action I want to cancel that email and have it not send.

How would I do that in django or python?

答:
If you didn't have access to cron, you could easily do this:

Write a model that stores the email, the time to send, and a BooleanField indicating if the email has been sent.

Write a view which selects all emails that haven't been sent yet but should have by now, and sends them.

Use something like OpenACS Uptime, Pingdom or any other service capable of sending HTTP GET requests periodically to call that view, and trigger the email sending. (Both are free, the former should request once every 15 minutes, and the latter can be configured to request up to every minute, and will do so from several locations.)

Sure, it's inelegant, but it's a method that works on basically any web host. I used to do something like this when I was writing PHP apps to run on a host that killed all processes after something like 15 seconds.


问:
Google Maps distance matrix - calculate travel zone using distance between origin and destination
Using Google Maps Distance Matrix I have the distance between two locations, I want to use that distance to determine the travel zone.

The current script I have written calculates and outputs the distance, I need assistance to find the travel zone.

jQuery is enabled.

```<code><script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk&callback=initMap">
</script>

     <script type="text/javascript">
        var origin = 'Perth, Australia',
            destination = 'Two Rocks, Australia',
            service = new google.maps.DistanceMatrixService(),
            zone;

        service.getDistanceMatrix(
            {
                origins: [origin],
                destinations: [destination],
                travelMode: google.maps.TravelMode.DRIVING,
                avoidHighways: false,
                avoidTolls: false
            },
            callback
        );

        function callback(response, status) {
            var orig = document.getElementById("orig"),
                dest = document.getElementById("dest"),
                dist = document.getElementById("dist");
                zone = document.getElementById("zone");

            if(status=="OK") {
                orig.value = response.destinationAddresses[0];
                dest.value = response.originAddresses[0];
                dist.value = response.rows[0].elements[0].distance.text;
            } else {
                alert("Error: " + status);
            }

            if (dist <= 30) {
                zone = 1;
            } else if (dist >= 30 && dist < 60) {
                zone = 2;
            } else if (dist >= 60 && dist < 90) {
                zone = 3;
            } else if (dist >= 90 && dist <= 120) {
                zone = 4;
            } else {
                zone = 'Out of range';
            }
        }

        </script>

        <label>
            <input id="orig" type="hidden"/>
            <input id="dest" type="hidden" />

            Distance: <input id="dist" type="text" value="distance" />
            Travel Zone: <input id="zone" type="text" value="zone" />

        </label>
</code>```

答:
Setup the variables making sure to get the distance as a number (without appending km)

```<code>    <script src='https://maps.googleapis.com/maps/api/js?key=key'></script>

    <script type="text/javascript">
    var origin = 'Perth, Australia',
        destination = '<?php echo $suburb; ?>, Australia',
        service = new google.maps.DistanceMatrixService();

    service.getDistanceMatrix(
        {
            origins: [origin],
            destinations: [destination],
            travelMode: google.maps.TravelMode.DRIVING,
            avoidHighways: false,
            avoidTolls: false
        },
        callback
    );

    function callback(response, status) {
        var orig = document.getElementById("orig"),
            dest = document.getElementById("dest"),
            dist = document.getElementById("dist"),
            zone = document.getElementById("zone");
            total = document.getElementById("total");

        if(status=="OK") {
            orig.value = response.destinationAddresses[0];
            dest.value = response.originAddresses[0];
            // return distance in metres
            dist.value = response.rows[0].elements[0].distance.value;

            // Use dist.value to calculate travel zone
            if (dist.value <= 30000) {
                zone.value = 0;
            } else if (dist.value >= 30000 && dist.value < 40000) {
                zone.value = 20;
            } else if (dist.value >= 40000 && dist.value < 50000) {
                zone.value = 40;
            } else if (dist.value >= 50000 && dist.value <= 60000) {
                zone.value = 80;
            } else if (dist.value >= 60000 && dist.value <= 70000) {
                zone.value = 150;
            } else if (dist.value >= 70000 && dist.value <= 80000) {
                zone.value = 190;
            } else {
                zone.value = 'Out of range';
            }
            total.value = Number(<?php echo $base; ?>) + Number(zone.value);

        } else {
            dist.value = 'Unknown Suburb';
        }

    }

    </script>
</code>```

Output the variables:

```<code><input id="orig" type="text"/>
<input id="dest" type="text" />
<input id="dist" type="text" />
<input id="zone" type="text" />
</code>```

Body:
Using Google Maps Distance Matrix I have the distance between two locations, I want to use that distance to determine the travel zone.

The current script I have written calculates and outputs the distance, I need assistance to find the travel zone.

jQuery is enabled.

            <input id="orig" type="hidden"/>
            <input id="dest" type="hidden" />

            Distance: <input id="dist" type="text" value="distance" />
            Travel Zone: <input id="zone" type="text" value="zone" />

Body:
Setup the variables making sure to get the distance as a number (without appending km)

    <script src='https://maps.googleapis.com/maps/api/js?key=key'></script>

    <script type="text/javascript">
    var origin = 'Perth, Australia',
        destination = '<?php echo $suburb; ?>, Australia',
        service = new google.maps.DistanceMatrixService();

    service.getDistanceMatrix(
        {
            origins: [origin],
            destinations: [destination],
            travelMode: google.maps.TravelMode.DRIVING,
            avoidHighways: false,
            avoidTolls: false
        },
        callback
    );

    function callback(response, status) {
        var orig = document.getElementById("orig"),
            dest = document.getElementById("dest"),
            dist = document.getElementById("dist"),
            zone = document.getElementById("zone");
            total = document.getElementById("total");

        if(status=="OK") {
            orig.value = response.destinationAddresses[0];
            dest.value = response.originAddresses[0];
            // return distance in metres
            dist.value = response.rows[0].elements[0].distance.value;

            // Use dist.value to calculate travel zone
            if (dist.value <= 30000) {
                zone.value = 0;
            } else if (dist.value >= 30000 && dist.value < 40000) {
                zone.value = 20;
            } else if (dist.value >= 40000 && dist.value < 50000) {
                zone.value = 40;
            } else if (dist.value >= 50000 && dist.value <= 60000) {
                zone.value = 80;
            } else if (dist.value >= 60000 && dist.value <= 70000) {
                zone.value = 150;
            } else if (dist.value >= 70000 && dist.value <= 80000) {
                zone.value = 190;
            } else {
                zone.value = 'Out of range';
            }
            total.value = Number(<?php echo $base; ?>) + Number(zone.value);

        } else {
            dist.value = 'Unknown Suburb';
        }

    }

    </script>

Output the variables:

<input id="orig" type="text"/>
<input id="dest" type="text" />
<input id="dist" type="text" />
<input id="zone" type="text" />


问:
Converting a 2d array into a 1d array
just curious on how to convert a 2d array into a 1d array. </p>

```<code>For example if my array was:

int[][] arr = {{2,3,4},
               {5,6,7}};

lets say I wanted it just to be transferred to a 1d array such as:

int[] arr = {2,3,4,5,6,7};
</code>```

答:
Assuming you're using Java 8+, you can create a Stream of int[] instances; then flatMapToInt that to an IntStream before converting it to an array. Which will do exactly as you describe. Like,

```<code>int[][] arr = { { 2, 3, 4 }, { 5, 6, 7 } };
int[] b = Stream.of(arr).flatMapToInt(IntStream::of).toArray();
System.out.println(Arrays.toString(b));
</code>```

Which outputs

```<code>[2, 3, 4, 5, 6, 7]
</code>```

Title: Converting a 2d array into a 1d array

Body:
just curious on how to convert a 2d array into a 1d array.

For example if my array was:

int[][] arr = {{2,3,4},
               {5,6,7}};

lets say I wanted it just to be transferred to a 1d array such as:

int[] arr = {2,3,4,5,6,7};

Body:
Assuming you're using Java 8+, you can create a Stream of int[] instances; then flatMapToInt that to an IntStream before converting it to an array. Which will do exactly as you describe. Like,

int[][] arr = { { 2, 3, 4 }, { 5, 6, 7 } };
int[] b = Stream.of(arr).flatMapToInt(IntStream::of).toArray();
System.out.println(Arrays.toString(b));

Which outputs

[2, 3, 4, 5, 6, 7]


问:
How do I import a specific version of a package using go get?
coming from a Node environment I used to install a specific version of a vendor lib into the project folder (node_modules) by telling npm to install that version of that lib from the package.json or even directly from the console, like so:

```<code>$ npm install express@4.0.0
</code>```

Then I used to import that version of that package in my project just with:

```<code>var express = require('express');
</code>```

Now, I want to do the same thing with go. How can I do that?
Is it possible to install a specific version of a package? If so, using a centralized $GOPATH, how can I import one version instead of another?

I would do something like this:

```<code>$ go get github.com/wilk/uuid@0.0.1
$ go get github.com/wilk/uuid@0.0.2
</code>```

But then, how can I make a difference during the import?

答:
dep is the official experiment for dependency management for Go language. It requires Go 1.8 or newer to compile.

To start managing dependencies using dep, run the following command from your project's root directory:

```<code>dep init
</code>```

After execution two files will be generated: Gopkg.toml ("manifest"), Gopkg.lock and  necessary packages will be downloaded into vendor directory.

Let's assume that you have the project which uses github.com/gorilla/websocket package. dep will generate following files:

Gopkg.toml

```<code># Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
#   name = "github.com/user/project"
#   version = "1.0.0"
#
# [[constraint]]
#   name = "github.com/user/project2"
#   branch = "dev"
#   source = "github.com/myfork/project2"
#
# [[override]]
#  name = "github.com/x/y"
#  version = "2.4.0"

[[constraint]]
  name = "github.com/gorilla/websocket"
  version = "1.2.0"
</code>```

Gopkg.lock

```<code># This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.

[[projects]]
  name = "github.com/gorilla/websocket"
  packages = ["."]
  revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b"
  version = "v1.2.0"

[solve-meta]
  analyzer-name = "dep"
  analyzer-version = 1
  inputs-digest = "941e8dbe52e16e8a7dff4068b7ba53ae69a5748b29fbf2bcb5df3a063ac52261"
  solver-name = "gps-cdcl"
  solver-version = 1
</code>```

There are commands which help you to update/delete/etc packages, please find more info on official github repo of dep (dependency management tool for Go).

Body:
coming from a Node environment I used to install a specific version of a vendor lib into the project folder (node_modules) by telling npm to install that version of that lib from the package.json or even directly from the console, like so:

$ npm install express@4.0.0

Then I used to import that version of that package in my project just with:

var express = require('express');

Now, I want to do the same thing with go. How can I do that?
Is it possible to install a specific version of a package? If so, using a centralized $GOPATH, how can I import one version instead of another?

I would do something like this:

$ go get github.com/wilk/uuid@0.0.1
$ go get github.com/wilk/uuid@0.0.2

But then, how can I make a difference during the import?

Body:
dep is the official experiment for dependency management for Go language. It requires Go 1.8 or newer to compile.

To start managing dependencies using dep, run the following command from your project's root directory:

dep init

After execution two files will be generated: Gopkg.toml ("manifest"), Gopkg.lock and  necessary packages will be downloaded into vendor directory.

Let's assume that you have the project which uses github.com/gorilla/websocket package. dep will generate following files:

Gopkg.toml

# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
#   name = "github.com/user/project"
#   version = "1.0.0"
#
# [[constraint]]
#   name = "github.com/user/project2"
#   branch = "dev"
#   source = "github.com/myfork/project2"
#
# [[override]]
#  name = "github.com/x/y"
#  version = "2.4.0"

[[constraint]]
  name = "github.com/gorilla/websocket"
  version = "1.2.0"

Gopkg.lock

# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.

[[projects]]
  name = "github.com/gorilla/websocket"
  packages = ["."]
  revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b"
  version = "v1.2.0"

[solve-meta]
  analyzer-name = "dep"
  analyzer-version = 1
  inputs-digest = "941e8dbe52e16e8a7dff4068b7ba53ae69a5748b29fbf2bcb5df3a063ac52261"
  solver-name = "gps-cdcl"
  solver-version = 1

There are commands which help you to update/delete/etc packages, please find more info on official github repo of dep (dependency management tool for Go).


问:
Save button does not work in fronend editor of Joomla after upgrading to 3.8.2
After upgrading to Joomla 3.8.2 from 3.6, users, be it super user, author or editor, cannot save anything via Front end editor on articles.
After opening the editor in an article, it opens as before and everything works as before in the editor until the user clicks on save button. Instead of saving and closing the article the page refreshes and goes back to editor with all the new changes still there, but nothing has been saved. The user can only click on cancel button and all the new changes will be deleted, then article editor will be closed.

I tried to make sure users have all the permissions under

Global Config >>> Article manager

Components >>> JCE >>> Profiles

Text Filters are all set to allow any script...

Changes on the same article can be made in back end with the same user.
Different editors such as JCE, ARK, CodeMirror and TinyEditor have been tried. No difference.
Actually this happens right after upgrading to 3.8.2 without manually making any changes in the configurations or editor.

It looks like it is a JavaScript conflict between save button and a component of another plugin. Any ideas or clues how this problem can be solved?

Here are some basic Info on my platform:

PHP 5.6.31

MySQL 5.5.57

Joomla! 3.8.2 Stable

Joomla Platform 13.1.0 Stable

Many thanks!

答:
On several sites, I have had a conflict with multiple things loading Google recaptcha.  Joomla recently added where the recaptcha can be required in frontend editing, but it doesn't appear when multiple instances of recaptcha are being loaded.  (I have had Joomla user, Engagebox, RSForms, etc also load).
Disabling recaptcha from frontend editing fixed it for me.
https://www.yellowwebmonkey.com/developer-blog/item/error-message-empty-solution-not-allowed