Skip to content

Commit

Permalink
test: fix test for arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuCocoa committed Apr 20, 2024
1 parent 31c3853 commit 2e34cff
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions test/unit/utils-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ import { withMocks } from '@appium/test-support';
import { fs } from '@appium/support';
import path from 'path';
import { fail } from 'assert';
import { arch } from 'os';

chai.should();
chai.use(chaiAsPromised);

function get_arch() {
return arch() === 'arm64' ? 'arm64' : 'x86_64';
}

describe('utils', function () {
describe('#getXctestrunFilePath', withMocks({fs}, function (mocks) {
const platformVersion = '12.0';
Expand Down Expand Up @@ -38,7 +43,7 @@ describe('utils', function () {
.withExactArgs(path.resolve(`${bootstrapPath}/${udid}_${sdkVersion}.xctestrun`))
.returns(false);
mocks.fs.expects('exists')
.withExactArgs(path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphoneos${sdkVersion}-arm64.xctestrun`))
.withExactArgs(path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphoneos${sdkVersion}-${get_arch()}.xctestrun`))
.returns(true);
mocks.fs.expects('copyFile')
.withExactArgs(
Expand All @@ -56,7 +61,7 @@ describe('utils', function () {
.withExactArgs(path.resolve(`${bootstrapPath}/${udid}_${sdkVersion}.xctestrun`))
.returns(false);
mocks.fs.expects('exists')
.withExactArgs(path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphonesimulator${sdkVersion}-x86_64.xctestrun`))
.withExactArgs(path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphonesimulator${sdkVersion}-${get_arch()}.xctestrun`))
.returns(false);
mocks.fs.expects('exists')
.withExactArgs(path.resolve(`${bootstrapPath}/${udid}_${platformVersion}.xctestrun`))
Expand All @@ -73,17 +78,17 @@ describe('utils', function () {
.withExactArgs(path.resolve(`${bootstrapPath}/${udid}_${sdkVersion}.xctestrun`))
.returns(false);
mocks.fs.expects('exists')
.withExactArgs(path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphonesimulator${sdkVersion}-x86_64.xctestrun`))
.withExactArgs(path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphonesimulator${sdkVersion}-${get_arch()}.xctestrun`))
.returns(false);
mocks.fs.expects('exists')
.withExactArgs(path.resolve(`${bootstrapPath}/${udid}_${platformVersion}.xctestrun`))
.returns(false);
mocks.fs.expects('exists')
.withExactArgs(path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphonesimulator${platformVersion}-x86_64.xctestrun`))
.withExactArgs(path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphonesimulator${platformVersion}-${get_arch()}.xctestrun`))
.returns(true);
mocks.fs.expects('copyFile')
.withExactArgs(
path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphonesimulator${platformVersion}-x86_64.xctestrun`),
path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphonesimulator${platformVersion}-${get_arch()}.xctestrun`),
path.resolve(`${bootstrapPath}/${udid}_${platformVersion}.xctestrun`)
)
.returns(true);
Expand All @@ -94,7 +99,7 @@ describe('utils', function () {
});

it('should raise an exception because of no files', async function () {
const expected = path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphonesimulator${sdkVersion}-x86_64.xctestrun`);
const expected = path.resolve(`${bootstrapPath}/WebDriverAgentRunner_iphonesimulator${sdkVersion}-${get_arch()}.xctestrun`);
mocks.fs.expects('exists').exactly(4).returns(false);

const deviceInfo = {isRealDevice: false, udid, platformVersion};
Expand Down Expand Up @@ -140,7 +145,7 @@ describe('utils', function () {
const deviceInfo = {isRealDevice: false, udid, platformVersion, platformName};

getXctestrunFileName(deviceInfo, '10.2.0').should.equal(
'WebDriverAgentRunner_iphonesimulator10.2.0-x86_64.xctestrun');
`WebDriverAgentRunner_iphonesimulator10.2.0-${get_arch()}.xctestrun`);
});

it('should return tvos format, real device', function () {
Expand All @@ -156,7 +161,7 @@ describe('utils', function () {
const deviceInfo = {isRealDevice: false, udid, platformVersion, platformName};

getXctestrunFileName(deviceInfo, '10.2.0').should.equal(
'WebDriverAgentRunner_tvOS_appletvsimulator10.2.0-x86_64.xctestrun');
`WebDriverAgentRunner_tvOS_appletvsimulator10.2.0-${get_arch()}.xctestrun`);
});
});
});

0 comments on commit 2e34cff

Please sign in to comment.