Browse Source

ci: Refactor mksnapshot test so that it doesn't stall. (#16886)

trop[bot] 6 years ago
parent
commit
225264f06b

+ 3 - 0
appveyor.yml

@@ -92,6 +92,9 @@ test_script:
   - if "%RUN_TESTS%"=="true" ( echo Running test suite & npm run test -- --ci --enable-logging)
   - cd ..
   - if "%RUN_TESTS%"=="true" ( echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg )
+  - echo "About to verify mksnapshot"
+  - if "%RUN_TESTS%"=="true" ( echo Verifying mksnapshot & python electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd% )
+  - echo "Done verifying mksnapshot"
 deploy_script:
   - cd electron
   - ps: >-

+ 2 - 2
script/verify-mksnapshot.py

@@ -39,7 +39,7 @@ def main():
             + context_snapshot
 
       test_path = os.path.join(SOURCE_ROOT, 'spec', 'fixtures', \
-                               'snapshot-items-available.js')
+                               'snapshot-items-available')
 
       if sys.platform == 'darwin':
         bin_files = glob.glob(os.path.join(app_path, '*.bin'))
@@ -64,7 +64,7 @@ def main():
   except KeyboardInterrupt:
     print 'Other error'
     returncode = 0
-
+  print 'Returning with error code: {0}'.format(returncode)
   return returncode
 
 

+ 11 - 5
spec/fixtures/snapshot-items-available.js → spec/fixtures/snapshot-items-available/main.js

@@ -2,19 +2,25 @@
 
 const { app } = require('electron')
 
-app.once('ready', () => {
+app.on('ready', () => {
+  let returnCode = 0
   try {
     const testValue = f() // eslint-disable-line no-undef
     if (testValue === 86) {
       console.log('ok test snapshot successfully loaded.')
-      app.exit(0)
     } else {
       console.log('not ok test snapshot could not be successfully loaded.')
-      app.exit(1)
+      returnCode = 1
     }
-    return
   } catch (ex) {
     console.log('Error running custom snapshot', ex)
-    app.exit(1)
+    returnCode = 1
   }
+  setImmediate(function () {
+    app.exit(returnCode)
+  })
+})
+
+process.on('exit', function (code) {
+  console.log('test snapshot exited with code: ' + code)
 })

+ 4 - 0
spec/fixtures/snapshot-items-available/package.json

@@ -0,0 +1,4 @@
+{
+  "name": "snapshot-items-available",
+  "main": "main.js"
+}