 838b26ee26
			
		
	
	
	838b26ee26
	
	
	
		
			
			* Add support for multiple mocha reporters Allows us to output to junit file and to console at the same time * Cleanup VSTS file Don't install depot_tools everytime as it is already installed. Only run tests if "RUN_TESTS" environment variable is set Only notify slack if "NOTIFY_SLACK" environment variable is set Don't use sccache for release builds Move CircleCI mac builds to VSTS * Only build mac PRS from forks Don't install depot_tools everytime as it is already installed. Only run tests if "RUN_TESTS" environment variable is set Only notify slack if "NOTIFY_SLACK" environment variable is set Don't use sccache for release builds Move CircleCI mac builds to VSTS Use sccache helper script * rename vsts-gn.yml to vsts.yml Make sure Electron isn't running before starting tests
		
			
				
	
	
		
			120 lines
		
	
	
	
		
			3.2 KiB
			
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			120 lines
		
	
	
	
		
			3.2 KiB
			
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <html>
 | |
| <head>
 | |
|   <meta name="referrer" content="always">
 | |
|   <link href="../node_modules/mocha/mocha.css" rel="stylesheet">
 | |
|   <script src="jquery-2.0.3.min.js"></script>
 | |
| </head>
 | |
| <body>
 | |
| 
 | |
| <div id="mocha"></div>
 | |
| 
 | |
| <script type="text/javascript" charset="utf-8">
 | |
| (function() {
 | |
|   // Deprecated APIs are still supported and should be tested.
 | |
|   process.throwDeprecation = false
 | |
| 
 | |
|   const path = require('path')
 | |
|   const electron = require('electron')
 | |
|   const { remote, ipcRenderer } = electron
 | |
| 
 | |
|   // Check if we are running in CI.
 | |
|   const isCi = remote.getGlobal('isCi')
 | |
| 
 | |
|   if (!isCi) {
 | |
|     const win = remote.getCurrentWindow()
 | |
|     win.show()
 | |
|     win.focus()
 | |
|   }
 | |
| 
 | |
|   // Show DevTools.
 | |
|   document.oncontextmenu = (e) => {
 | |
|     remote.getCurrentWindow().inspectElement(e.clientX, e.clientY)
 | |
|   }
 | |
| 
 | |
|   // Rediret all output to browser.
 | |
|   if (isCi) {
 | |
|     global.__defineGetter__('console', function () {
 | |
|       return {
 | |
|         log: (...args) => ipcRenderer.send('console.log', args),
 | |
|         error: (...args) => ipcRenderer.send('console.error', args)
 | |
|       }
 | |
|     })
 | |
|   }
 | |
| 
 | |
|   const { Coverage } = require('electabul')
 | |
|   const Mocha = require('mocha')
 | |
|   const mochaOptions = {}
 | |
|   if (process.env.MOCHA_REPORTER) {
 | |
|     mochaOptions.reporter = process.env.MOCHA_REPORTER
 | |
|   }
 | |
|   if (process.env.MOCHA_MULTI_REPORTERS) {
 | |
|     mochaOptions.reporterOptions = {
 | |
|       reporterEnabled: process.env.MOCHA_MULTI_REPORTERS
 | |
|     }
 | |
|   }
 | |
|   const mocha = new Mocha(mochaOptions)
 | |
| 
 | |
|   if (!process.env.MOCHA_REPORTER) {
 | |
|     mocha.ui('bdd').reporter(isCi ? 'tap' : 'html')
 | |
|   }
 | |
|   mocha.timeout(isCi ? 30000 : 10000)
 | |
| 
 | |
|   const query = Mocha.utils.parseQuery(window.location.search || '')
 | |
|   if (query.grep) mocha.grep(query.grep)
 | |
|   if (query.invert) mocha.invert()
 | |
| 
 | |
|   // Read all test files.
 | |
|   const walker = require('walkdir').walk(path.dirname(__dirname), {
 | |
|     no_recurse: true
 | |
|   })
 | |
| 
 | |
|   const crashSpec = 'api-crash-reporter-spec.js'
 | |
| 
 | |
|   // This allows you to run specific modules only:
 | |
|   // npm run test -match=menu
 | |
|   const moduleMatch = process.env.npm_config_match
 | |
|     ? new RegExp(process.env.npm_config_match, 'g')
 | |
|     : null
 | |
| 
 | |
|   walker.on('file', (file) => {
 | |
|     if (/-spec\.js$/.test(file) && !file.includes(crashSpec) &&
 | |
|         (!moduleMatch || moduleMatch.test(file))) {
 | |
|       mocha.addFile(file)
 | |
|     }
 | |
|   })
 | |
| 
 | |
|   walker.on('end', () => {
 | |
|     if (!process.env.npm_config_match || new RegExp(process.env.npm_config_match, 'g').test(crashSpec)) {
 | |
|       mocha.addFile(path.resolve(__dirname, '..', crashSpec))
 | |
|     }
 | |
| 
 | |
|     const runner = mocha.run(() => {
 | |
|       if (isCi && runner.hasOnly) {
 | |
|         try {
 | |
|           throw new Error('A spec contains a call to it.only or describe.only and should be reverted.')
 | |
|         } catch (error) {
 | |
|           console.error(error.stack || error)
 | |
|         }
 | |
|         ipcRenderer.send('process.exit', 1)
 | |
|         return
 | |
|       }
 | |
| 
 | |
|       Mocha.utils.highlightTags('code')
 | |
| 
 | |
|       const coverage = new Coverage({
 | |
|         libPath: path.join(__dirname, '..', '..', 'lib'),
 | |
|         outputPath: path.join(__dirname, '..', '..', 'out', 'coverage'),
 | |
|         formats: ['text', 'lcov']
 | |
|       })
 | |
|       coverage.addCoverage(ipcRenderer.sendSync('get-main-process-coverage'))
 | |
|       coverage.generateReport()
 | |
| 
 | |
|       if (isCi) {
 | |
|         ipcRenderer.send('process.exit', runner.failures)
 | |
|       }
 | |
|     })
 | |
|   })
 | |
| })()
 | |
| </script>
 | |
| </body>
 | |
| </html>
 |