[tests][bridge] added device time drift checks
This commit is contained in:
parent
1572aa10a2
commit
c69c6b9082
30
tests-new/bridge/env/node/context.js
vendored
30
tests-new/bridge/env/node/context.js
vendored
@ -3,8 +3,10 @@ global.bridge.context = null;
|
|||||||
|
|
||||||
const consoleContext = require('./console');
|
const consoleContext = require('./console');
|
||||||
const { createContext } = require('vm');
|
const { createContext } = require('vm');
|
||||||
|
const chalk = require('chalk');
|
||||||
|
|
||||||
let customBridgeProps = [];
|
let customBridgeProps = [];
|
||||||
|
let driftCheckStart = null;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/**
|
/**
|
||||||
@ -58,6 +60,34 @@ module.exports = {
|
|||||||
console: consoleContext(),
|
console: consoleContext(),
|
||||||
__bridgeNode: {
|
__bridgeNode: {
|
||||||
_ready() {
|
_ready() {
|
||||||
|
if (!driftCheckStart) {
|
||||||
|
driftCheckStart = Date.now();
|
||||||
|
global.bridge.context.__driftCheck(1);
|
||||||
|
} else {
|
||||||
|
setTimeout(() => process.emit('bridge-attached'), 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_callbackDriftCheck() {
|
||||||
|
const timeTaken = Date.now() - driftCheckStart;
|
||||||
|
if (timeTaken > 5000) {
|
||||||
|
console.log(
|
||||||
|
`${chalk.blue(
|
||||||
|
'[bridge] ⚠️ '
|
||||||
|
)} It looks like there's an issue with device timer performance...`
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
`${chalk.blue(
|
||||||
|
'[bridge] ⚠️ '
|
||||||
|
)} You may experience slow testing times as a result - ensure your device date/time correctly matches your debugger machine.`
|
||||||
|
);
|
||||||
|
// todo android only
|
||||||
|
// fake the RN warning for this
|
||||||
|
global.bridge.context.console.warn(
|
||||||
|
`Debugger and device times have drifted. ` +
|
||||||
|
`Please correct this by running adb shell "date \`date +%m%d%H%M%Y.%S\`" on your debugger machine.`
|
||||||
|
);
|
||||||
|
}
|
||||||
setTimeout(() => process.emit('bridge-attached'), 1);
|
setTimeout(() => process.emit('bridge-attached'), 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
2
tests-new/bridge/env/node/vm.js
vendored
2
tests-new/bridge/env/node/vm.js
vendored
@ -47,13 +47,11 @@ async function downloadBundle(bundleUrl) {
|
|||||||
|
|
||||||
async function getBundle(request) {
|
async function getBundle(request) {
|
||||||
if (bundle) return bundle;
|
if (bundle) return bundle;
|
||||||
console.log('');
|
|
||||||
console.log(
|
console.log(
|
||||||
`${chalk.blue(
|
`${chalk.blue(
|
||||||
'[bridge]'
|
'[bridge]'
|
||||||
)} debugger has connected! Downloading app JS bundle...`
|
)} debugger has connected! Downloading app JS bundle...`
|
||||||
);
|
);
|
||||||
console.log('');
|
|
||||||
|
|
||||||
const parsedUrl = url.parse(request.url, true);
|
const parsedUrl = url.parse(request.url, true);
|
||||||
invariant(parsedUrl.query);
|
invariant(parsedUrl.query);
|
||||||
|
4
tests-new/bridge/env/rn.js
vendored
4
tests-new/bridge/env/rn.js
vendored
@ -36,6 +36,10 @@ if (Platform.OS === 'ios' && !bridgeNode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global.__driftCheck = delay => {
|
||||||
|
setTimeout(bridgeNode._callbackDriftCheck, delay);
|
||||||
|
};
|
||||||
|
|
||||||
let hasInitialized = false;
|
let hasInitialized = false;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user