2
0
mirror of synced 2025-01-12 07:04:21 +00:00

Merge remote-tracking branch 'origin/bridge-detox' into bridge-detox

This commit is contained in:
Salakar 2018-03-27 23:00:27 +01:00
commit 58dc8a4cac
4 changed files with 100 additions and 70 deletions

View File

@ -10,7 +10,10 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
@ -19,4 +22,3 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro
android.useDeprecatedNdk=true
android.enableAapt2=false
org.gradle.jvmargs=-Xmx1536M

View File

@ -1,12 +1,18 @@
/* eslint-disable no-param-reassign */
/* eslint-disable no-param-reassign,global-require */
global.bridge = {};
require('./source-map');
const detox = require('detox');
const ws = require('./ws');
const ready = require('./ready');
const coverage = require('./coverage');
let detox;
try {
detox = require('detox');
} catch (e) {
// ignore
}
if (detox) {
/* ---------------------
* DEVICE OVERRIDES
* --------------------- */
@ -63,10 +69,13 @@ detox.cleanup = async (...args) => {
}
await detoxOriginalCleanup(...args);
};
}
// setup after hook to ensure final context coverage is captured
process.nextTick(() => {
if (global.after) {
after(() => {
coverage.collect();
});
}
});

View File

@ -1,12 +1,16 @@
/* eslint-disable no-param-reassign */
const Mocha = require('mocha');
const ErrorStack = require('error-stack-parser');
const { SourceMapConsumer } = require('source-map');
/* eslint-disable no-param-reassign,global-require */
let Mocha;
try {
Mocha = require('mocha');
} catch (e) {
// ignore
}
let bundleFileName = null;
const Runner = Mocha.Runner;
let sourceMapConsumer = null;
const originalFail = Runner.prototype.fail;
const ErrorStack = require('error-stack-parser');
const { SourceMapConsumer } = require('source-map');
/**
* Convert an error frame into a source mapped string
@ -23,8 +27,13 @@ function frameToStr(parsed) {
parsed.columnNumber})`;
}
// override mocha fail so we can replace stack traces
Runner.prototype.fail = function fail(test, error) {
/**
* Convert an errors stack frames to their original source mapped positions
*
* @param error
* @return {*}
*/
function sourceMappedError(error) {
const original = error.stack.split('\n');
const parsed = ErrorStack.parse(error);
@ -37,10 +46,20 @@ Runner.prototype.fail = function fail(test, error) {
}
error.stack = newStack.join('\n');
return originalFail.call(this, test, error);
return error;
}
if (Mocha) {
// override mocha fail so we can replace stack traces
const Runner = Mocha.Runner;
const originalFail = Runner.prototype.fail;
Runner.prototype.fail = function fail(test, error) {
return originalFail.call(this, test, sourceMappedError(error));
};
}
module.exports = {
sourceMappedError,
/**
* Build a source map consumer from source map bundle contents
* @param str

View File

@ -87,7 +87,7 @@ module.exports = {
case EXECUTE: {
const script = await getBundle(request);
if (global.bridge.context == null) {
if (global.bridge.context === null) {
throw new Error('VM context was not prepared.');
}
if (request.inject) {
@ -105,7 +105,7 @@ module.exports = {
let returnValue = [[], [], [], 0];
try {
if (
global.bridge.context != null &&
global.bridge.context !== null &&
typeof global.bridge.context.__fbBatchedBridge === 'object'
) {
returnValue = global.bridge.context.__fbBatchedBridge[method].apply(