Skip to content

Commit ebee70a

Browse files
committed
fix: normalize username and UID in build settings fixture
The show-build-settings fixture had hardcoded username and UID values that would cause test failures on other developer machines. Added normalizer rules for ALTERNATE_OWNER, INSTALL_OWNER, USER, VERSION_INFO_BUILDER, and UID build settings.
1 parent b97e21d commit ebee70a

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/snapshot-tests/__fixtures__/project-discovery/show-build-settings--success.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Settings
1515
ALLOW_TARGET_PLATFORM_SPECIALIZATION = NO
1616
ALTERNATE_GROUP = staff
1717
ALTERNATE_MODE = u+w,go-w,a+rX
18-
ALTERNATE_OWNER = cameroncooke
18+
ALTERNATE_OWNER = <USER>
1919
ALTERNATIVE_DISTRIBUTION_WEB = NO
2020
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO
2121
ALWAYS_SEARCH_USER_PATHS = NO
@@ -293,7 +293,7 @@ Settings
293293
INSTALL_DIR = /tmp/CalculatorApp.dst/Applications
294294
INSTALL_GROUP = staff
295295
INSTALL_MODE_FLAG = u+w,go-w,a+rX
296-
INSTALL_OWNER = cameroncooke
296+
INSTALL_OWNER = <USER>
297297
INSTALL_PATH = /Applications
298298
INSTALL_ROOT = /tmp/CalculatorApp.dst
299299
IPHONEOS_DEPLOYMENT_TARGET = 17.0
@@ -562,13 +562,13 @@ Settings
562562
TREAT_MISSING_BASELINES_AS_TEST_FAILURES = NO
563563
TREAT_MISSING_SCRIPT_PHASE_OUTPUTS_AS_ERRORS = NO
564564
TVOS_DEPLOYMENT_TARGET = 26.4
565-
UID = 501
565+
UID = <UID>
566566
UNINSTALLED_PRODUCTS_DIR = <HOME>/Library/Developer/Xcode/DerivedData/CalculatorApp-<HASH>/Build/Intermediates.noindex/UninstalledProducts
567567
UNLOCALIZED_RESOURCES_FOLDER_PATH = CalculatorApp.app
568568
UNLOCALIZED_RESOURCES_FOLDER_PATH_SHALLOW_BUNDLE_NO = CalculatorApp.app/Resources
569569
UNLOCALIZED_RESOURCES_FOLDER_PATH_SHALLOW_BUNDLE_YES = CalculatorApp.app
570570
UNSTRIPPED_PRODUCT = NO
571-
USER = cameroncooke
571+
USER = <USER>
572572
USER_APPS_DIR = <HOME>/Applications
573573
USER_LIBRARY_DIR = <HOME>/Library
574574
USE_DYNAMIC_NO_PIC = YES
@@ -579,7 +579,7 @@ Settings
579579
VALID_ARCHS = arm64 arm64e armv7 armv7s
580580
VERBOSE_PBXCP = NO
581581
VERSIONPLIST_PATH = CalculatorApp.app/version.plist
582-
VERSION_INFO_BUILDER = cameroncooke
582+
VERSION_INFO_BUILDER = <USER>
583583
VERSION_INFO_FILE = CalculatorApp_vers.c
584584
VERSION_INFO_STRING = "@(#)PROGRAM:CalculatorApp PROJECT:CalculatorApp-1"
585585
WATCHOS_DEPLOYMENT_TARGET = 26.4

src/snapshot-tests/normalize.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ export function normalizeSnapshotOutput(text: string): string {
8787
normalized = normalized.replace(/~\//g, '<HOME>/');
8888
normalized = normalized.replace(/(?<=\s|:)~(?=\s|$)/gm, '<HOME>');
8989

90+
const username = os.userInfo().username;
91+
normalized = normalized.replace(
92+
new RegExp(`((?:ALTERNATE_OWNER|INSTALL_OWNER|USER|VERSION_INFO_BUILDER)\\s*=\\s*)${escapeRegex(username)}`, 'g'),
93+
'$1<USER>',
94+
);
95+
normalized = normalized.replace(
96+
new RegExp(`(UID\\s*=\\s*)${os.userInfo().uid}`, 'g'),
97+
'$1<UID>',
98+
);
99+
90100
const tmpDir = os.tmpdir();
91101
normalized = normalized.replace(
92102
new RegExp(escapeRegex(tmpDir) + '/[A-Za-z0-9._-]+/', 'g'),

0 commit comments

Comments
 (0)