-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running on windows support #628
Changes from all commits
989e45e
b950f2a
5982396
4430484
9093c2d
a6169b2
a50ebe7
3288a98
2aace19
b0374e8
d809041
80d20cb
3ff87ab
0b6912c
8e4a325
9e9fa8a
dcc7bc5
86e7f7f
7f03f0b
610c947
140ad0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env node | ||
const cp = require('child_process'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
const detoxPath = path.join(process.cwd(), 'node_modules/detox'); | ||
const detoxPackageJsonPath = path.join(detoxPath, 'package.json'); | ||
|
||
if (fs.existsSync(detoxPackageJsonPath)) { | ||
// { shell: true } option seems to break quoting on windows? Otherwise this would be much simpler. | ||
if (process.platform === 'win32') { | ||
const result = cp.spawnSync( | ||
'cmd', | ||
['/c', path.join(process.cwd(), 'node_modules/.bin/detox.cmd')].concat(process.argv.slice(2)), | ||
{ stdio: 'inherit' }); | ||
process.exit(result.status); | ||
} else { | ||
const result = cp.spawnSync( | ||
path.join(process.cwd(), 'node_modules/.bin/detox'), | ||
process.argv.slice(2), | ||
{ stdio: 'inherit' }); | ||
process.exit(result.status); | ||
} | ||
} else { | ||
console.log(detoxPackageJsonPath); | ||
console.log("detox is not installed in this directory"); | ||
process.exit(1); | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
"test": ":" | ||
}, | ||
"bin": { | ||
"detox": "./cli.sh" | ||
"detox": "./cli.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const childProcess = require('child_process'); | ||
const fs = require('fs-extra'); | ||
|
||
// Just make the usage a little prettier | ||
function sh(cmdline, opts) { | ||
const args = cmdline.split(' '); | ||
const cmd = args.shift(); | ||
return childProcess.execFileSync(cmd, args, opts); | ||
} | ||
|
||
if (process.platform === 'darwin') { | ||
console.log("\nPackaging Detox iOS sources"); | ||
|
||
fs.removeSync('Detox-ios-src.tbz'); | ||
// Prepare Earl Grey without building | ||
sh("ios/EarlGrey/Scripts/setup-earlgrey.sh"); | ||
sh("find ./ios -name Build -type d -exec rm -rf {} ;"); | ||
|
||
sh("tar -cjf ../Detox-ios-src.tbz .", { cwd: "ios" }); | ||
} | ||
|
||
if (process.argv[2] === "android" || process.argv[3] === "android") { | ||
console.log("\nBuilding Detox aars"); | ||
const aars = [ | ||
"detox-minReactNative44-debug.aar", | ||
"detox-minReactNative46-debug.aar", | ||
"detox-minReactNative44-release.aar", | ||
"detox-minReactNative46-release.aar" | ||
]; | ||
aars.forEach(aar => { | ||
fs.removeSync(aar); | ||
}); | ||
|
||
sh("./gradlew assembleDebug assembleRelease", { | ||
cwd: "android", | ||
stdio: "inherit", | ||
shell: true | ||
}); | ||
|
||
aars.forEach(aar => { | ||
fs.copySync(`android/detox/build/outputs/aar/${aar}`, aar); | ||
}); | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
if (process.platform === "darwin") { | ||
require("child_process").execSync(`${__dirname}/build_framework.ios.sh`, { | ||
stdio: "inherit" | ||
}); | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
const _ = require('lodash'); | ||
const configurationsMock = require('../configurations.mock'); | ||
|
||
const path = require('path'); | ||
|
||
const validScheme = configurationsMock.validOneDeviceAndSession; | ||
const invalidDeviceNoBinary = configurationsMock.invalidDeviceNoBinary; | ||
const invalidDeviceNoDeviceName = configurationsMock.invalidDeviceNoDeviceName; | ||
|
@@ -547,11 +548,11 @@ describe('Device', () => { | |
|
||
it(`should accept absolute path for binary`, async () => { | ||
const actualPath = await launchAndTestBinaryPath('absolutePath'); | ||
expect(actualPath).toEqual('/tmp/abcdef/123'); | ||
expect(actualPath).toEqual(process.platform === 'win32' ? 'C:\\Temp\\abcdef\\123' : '/tmp/abcdef/123'); | ||
}); | ||
|
||
it(`should accept relative path for binary`, async () => { | ||
const actualPath = await launchAndTestBinaryPath('relativePath'); | ||
expect(actualPath).toEqual(`${process.cwd()}/abcdef/123`); | ||
expect(actualPath).toEqual(path.join(process.cwd(), 'abcdef/123')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be split to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Path will normalise separators, and windows in fine with either except for binary paths (where they are ambiguous with switches) |
||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,10 +52,18 @@ class EmulatorDriver extends AndroidDriver { | |
} | ||
|
||
await this._fixEmulatorConfigIniSkinName(name); | ||
await this.emulator.boot(name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What was the issue here ? boot should return a valid device, either it's shutdown or already booted. If it doesn't we may have issue with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I now see the comments here. Not sure how to proceed here. This fix is in bad taste IMO. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could experiment a bit, I suspect redirecting to different files should fix it, but this was a less user visible change (eg. .gitignore) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, gave it a try and it still hangs on startup with no output to the log file even if it's a new file each time. |
||
|
||
const adbDevices = await this.adb.devices(); | ||
const filteredDevices = _.filter(adbDevices, {type: 'emulator', name: name}); | ||
let adbDevices = await this.adb.devices(); | ||
let filteredDevices = _.filter(adbDevices, {type: 'emulator', name: name}); | ||
|
||
// If it's not already running, start it now. | ||
if (!filteredDevices.length) { | ||
await this.emulator.boot(name); | ||
|
||
// Refresh devices after boot completes. | ||
adbDevices = await this.adb.devices(); | ||
filteredDevices = _.filter(adbDevices, {type: 'emulator', name: name}); | ||
} | ||
|
||
let adbName; | ||
switch (filteredDevices.length) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm and yarn install detox-server at different locations.
it might be either it
node_modules
or innode_modules/detox/node_modules
I am not familiar with
require.resolve('detox-server/package.json');
trick. Will it cover both cases ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it's the standard hack to find the location of an NPM package the same way node does, since every NPM package has a
package.json
. Remember:require / require.resolve('foo/bar')
looks upfoo
in node_modules, then addsbar
to that path.../bar
it would use themain
field, which is likely to be in a nested subdirpackage.json
always exists.