8000 chore: fix tests (#5786) · NativeScript/nativescript-cli@2577ff7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2577ff7

Browse files
chore: fix tests (#5786)
Co-authored-by: Nathan Walker <walkerrunpdx@gmail.com>
1 parent 6d133d9 commit 2577ff7

File tree

2 files changed

+45
-23
lines changed

2 files changed

+45
-23
lines changed

lib/services/ios/xcodebuild-args-service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export class XcodebuildArgsService implements IXcodebuildArgsService {
115115
platformData.projectRoot,
116116
`${projectData.projectName}.xcworkspace`
117117
);
118+
118119
// Introduced in Xcode 14+
119120
// ref: https://forums.swift.org/t/telling-xcode-14-beta-4-to-trust-build-tool-plugins-programatically/59305/5
120121
const skipPackageValidation = "-skipPackagePluginValidation";

test/services/ios/xcodebuild-args-service.ts

Lines changed: 44 additions & 23 deletions
< 8000 td data-grid-cell-id="diff-556455dd68a39c503dcada70398cfaf83ee384e2d50316c8d34ee7035968bdea-45-61-0" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionNum-bgColor, var(--diffBlob-addition-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as path from "path";
55
import * as _ from "lodash";
66
import { assert } from "chai";
77
import { IInjector } from "../../../lib/common/definitions/yok";
8+
import { BUILD_XCCONFIG_FILE_NAME } from "../../../lib/constants";
89

910
function createTestInjector(data: {
1011
logLevel: string;
@@ -18,7 +19,13 @@ function createTestInjector(data: {
1819
getDevicesForPlatform: () => data.connectedDevices || [],
1920
});
2021
injector.register("fs", {
21-
exists: () => data.hasProjectWorkspace,
22+
exists: (filepath: string) => {
23+
if (filepath.includes(BUILD_XCCONFIG_FILE_NAME)) {
24+
return true;
25+
} else {
26+
return data.hasProjectWorkspace;
27+
}
28+
},
2229
});
2330
injector.register("logger", {
2431
getLevel: () => data.logLevel,
@@ -32,6 +39,8 @@ function createTestInjector(data: {
3239
}
3340

3441
const projectRoot = "path/to/my/app/folder/platforms/ios";
42+
const normalizedPlatformName = "iOS";
43+
const appResourcesDirectoryPath = "App_Resources";
3544
const projectName = "myApp";
3645
const buildOutputPath = path.join(projectRoot, projectName, "archive");
3746

@@ -43,18 +52,27 @@ function getCommonArgs() {
4352
}
4453

4554
function getXcodeProjectArgs(data?: { hasProjectWorkspace: boolean }) {
55+
const extraArgs = [
56+
"-scheme",
57+
projectName,
58+
"-skipPackagePluginValidation",
59+
"-xcconfig",
60+
path.join(
61+
appResourcesDirectoryPath,
62+
normalizedPlatformName,
63+
BUILD_XCCONFIG_FILE_NAME
64+
),
65+
];
4666
return data && data.hasProjectWorkspace
4767
? [
4868
"-workspace",
4969
path.join(projectRoot, `${projectName}.xcworkspace`),
50-
"-scheme",
51-
projectName,
70+
...extraArgs,
5271
]
5372
: [
5473
"-project",
5574
path.join(projectRoot, `${projectName}.xcodeproj`),
56-
"-scheme",
57-
projectName,
75+
...extraArgs,
5876
];
5977
}
6078

@@ -84,11 +102,12 @@ describe("xcodebuildArgsService", () => {
84102
const xcodebuildArgsService = injector.resolve(
85103
"xcodebuildArgsService"
86104
);
87-
const actualArgs = await xcodebuildArgsService.getBuildForSimulatorArgs(
88-
{ projectRoot },
89-
{ projectName },
90-
buildConfig
91-
);
105+
const actualArgs =
106+
await xcodebuildArgsService.getBuildForSimulatorArgs(
107+
{ projectRoot, normalizedPlatformName },
108+
{ projectName, appResourcesDirectoryPath },
109+
buildConfig
110+
);
92111

93112
const expectedArgs = [
94113
"ONLY_ACTIVE_ARCH=NO",
@@ -114,8 +133,7 @@ describe("xcodebuildArgsService", () => {
114133
describe("getBuildForDeviceArgs", () => {
115134
const testCases = [
116135
{
117-
name:
118-
"should return correct args when there are more than one connected device",
136+
name: "should return correct args when there are more than one connected device",
119137
connectedDevices: [
120138
{ deviceInfo: { activeArchitecture: "arm64" } },
121139
{ deviceInfo: { activeArchitecture: "armv7" } },
@@ -125,8 +143,7 @@ describe("xcodebuildArgsService", () => {
125143
),
126144
},
127145
{
128-
name:
129-
"should return correct args when there is only one connected device",
146+
name: "should return correct args when there is only one connected device",
130147
connectedDevices: [{ deviceInfo: { activeArchitecture: "arm64" } }],
131148
expectedArgs: ["-sdk", "iphoneos"].concat(getCommonArgs()),
132149
},
@@ -150,21 +167,25 @@ describe("xcodebuildArgsService", () => {
150167

151168
const platformData = {
152169
projectRoot,
170+
normalizedPlatformName,
153171
getBuildOutputPath: () => buildOutputPath,
154172
};
155-
const projectData = { projectName };
173+
const projectData = {
174+
projectName,
175+
appResourcesDirectoryPath,
176+
};
156177
const buildConfig = {
157178
buildForDevice: true,
158179
release: configuration === "Release",
159180
};
160-
const xcodebuildArgsService: IXcodebuildArgsService = injector.resolve(
161-
"xcodebuildArgsService"
162-
);
163-
const actualArgs = await xcodebuildArgsService.getBuildForDeviceArgs(
164-
<any>platformData,
165-
<any>projectData,
166-
<any>buildConfig
167-
);
181+
const xcodebuildArgsService: IXcodebuildArgsService =
182+
injector.resolve("xcodebuildArgsService");
183+
const actualArgs =
184+
await xcodebuildArgsService.getBuildForDeviceArgs(
185+
<any>platformData,
186+
<any>projectData,
187+
<any>buildConfig
188+
);
168189

169190
const expectedArgs = [
170191
"-destination",

0 commit comments

Comments
 (0)
0