-
Notifications
You must be signed in to change notification settings - Fork 906
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(macCatalyst): construct correct path for executable
- targetBuildDir var now has `-maccatalyst` in it before it gets to this method, so no need to add it again - gracefully handle if -maccatalyst exists or not as area regresses frequently - fail fast with error message if targetBuildDir does not exist at all - add unit test for the with and without -maccatalyst case plus verify ios did not regress
- Loading branch information
Showing
2 changed files
with
125 additions
and
7 deletions.
There are no files selected for viewing
97 changes: 97 additions & 0 deletions
97
packages/cli-platform-apple/src/commands/runCommand/__tests__/getBuildPath.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import path from 'path'; | ||
import fs from 'fs'; | ||
import {getTempDirectory} from '../../../../../../jest/helpers'; | ||
import {BuildSettings} from '../getBuildSettings'; | ||
import {getBuildPath} from '../getBuildPath'; | ||
|
||
const targetBuildDirName = 'foo'; | ||
const targetBuildDirNameWithMaccatalyst = `${targetBuildDirName}-maccatalyst`; | ||
const executableFolderPath = path.join('foo.app', 'Contents', 'MacOS', 'foo'); | ||
|
||
test('correctly determines macCatalyst build artifact path new style', async () => { | ||
// setup: | ||
const tmpBuildPath = getTempDirectory('maccatalyst-test-dir'); | ||
fs.mkdirSync(path.join(tmpBuildPath, targetBuildDirNameWithMaccatalyst), { | ||
recursive: true, | ||
}); | ||
|
||
// - create buildSettings object that represents this to CLI | ||
const buildSettings: BuildSettings = { | ||
TARGET_BUILD_DIR: path.join( | ||
tmpBuildPath, | ||
targetBuildDirNameWithMaccatalyst, | ||
), | ||
EXECUTABLE_FOLDER_PATH: executableFolderPath, | ||
FULL_PRODUCT_NAME: 'unused-in-this-test', | ||
INFOPLIST_PATH: 'unused-in-this-test', | ||
}; | ||
|
||
// test: | ||
// - send our buildSettings in and see what build path comes out | ||
const buildPath = await getBuildPath(buildSettings, 'ios', true); | ||
|
||
// assert: | ||
expect(buildPath).toBe( | ||
path.join( | ||
tmpBuildPath, | ||
targetBuildDirNameWithMaccatalyst, | ||
executableFolderPath, | ||
), | ||
); | ||
}); | ||
|
||
test('correctly determines macCatalyst build artifact path old style', async () => { | ||
// setup: | ||
const tmpBuildPath = getTempDirectory('maccatalyst-test-dir'); | ||
fs.mkdirSync(path.join(tmpBuildPath, targetBuildDirNameWithMaccatalyst), { | ||
recursive: true, | ||
}); | ||
|
||
// - create buildSettings object that represents this to CLI | ||
// FIXME get the build settings as side effect from project definition, | ||
// because it's the translation of project settings to path that fails | ||
const buildSettings: BuildSettings = { | ||
TARGET_BUILD_DIR: path.join(tmpBuildPath, targetBuildDirName), | ||
EXECUTABLE_FOLDER_PATH: executableFolderPath, | ||
FULL_PRODUCT_NAME: 'unused-in-this-test', | ||
INFOPLIST_PATH: 'unused-in-this-test', | ||
}; | ||
|
||
// test: | ||
// - send our buildSettings in and see what build path comes out | ||
const buildPath = await getBuildPath(buildSettings, 'ios', true); | ||
|
||
// assert: | ||
expect(buildPath).toBe( | ||
path.join( | ||
tmpBuildPath, | ||
targetBuildDirNameWithMaccatalyst, | ||
executableFolderPath, | ||
), | ||
); | ||
}); | ||
|
||
test('correctly determines iOS build artifact path', async () => { | ||
// setup: | ||
const tmpBuildPath = getTempDirectory('ios-test-dir'); | ||
fs.mkdirSync(path.join(tmpBuildPath, targetBuildDirName), { | ||
recursive: true, | ||
}); | ||
|
||
// - create buildSettings object that represents this to CLI | ||
const buildSettings: BuildSettings = { | ||
TARGET_BUILD_DIR: path.join(tmpBuildPath, targetBuildDirName), | ||
EXECUTABLE_FOLDER_PATH: executableFolderPath, | ||
FULL_PRODUCT_NAME: 'unused-in-this-test', | ||
INFOPLIST_PATH: 'unused-in-this-test', | ||
}; | ||
|
||
// test: | ||
// - send our buildSettings in and see what build path comes out | ||
const buildPath = await getBuildPath(buildSettings); | ||
|
||
// assert: | ||
expect(buildPath).toBe( | ||
path.join(tmpBuildPath, targetBuildDirName, executableFolderPath), | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters