Skip to content

Fix resuse_simulator value always being True - #2985

Merged
keith merged 2 commits into
bazelbuild:mainfrom
john-flanagan:jflan/resuse-simulator-fix
Oct 27, 2026
Merged

keith merged 2 commits into
bazelbuild:mainfrom
john-flanagan:jflan/resuse-simulator-fix

Conversation

@john-flanagan

Copy link
Copy Markdown
Contributor

resuse_simulator was always being set to True because of the default value of the --reuse-simulator argument.

This PR updates the logic not include a default value for --reuse-simulator directly, while still defaulting to True when the argument is missing and SIMULATOR_REUSE_SIMULATOR is not 0 or False.

The previous check for os.getenv("SIMULATOR_REUSE_SIMULATOR") is not None wasn't working correctly either because the template always set either SIMULATOR_REUSE_SIMULATOR=1 or SIMULATOR_REUSE_SIMULATOR= which resolve to "1" and "" respectively, both of which returned True from is not None.

I added a print statement just below the reuse_simulator logic to illustrate the problem

Before

$ SIMULATOR_DEVICE_TYPE="iPhone 15" SIMULATOR_REUSE_SIMULATOR= ./simulator_creator.py
Reuse simulator True

$ SIMULATOR_DEVICE_TYPE="iPhone 15" SIMULATOR_REUSE_SIMULATOR=1 ./simulator_creator.py
Reuse simulator True

$ SIMULATOR_DEVICE_TYPE="iPhone 15" SIMULATOR_REUSE_SIMULATOR=True ./simulator_creator.py
Reuse simulator True

$ SIMULATOR_DEVICE_TYPE="iPhone 15" SIMULATOR_REUSE_SIMULATOR=0 ./simulator_creator.py
Reuse simulator True

$ SIMULATOR_DEVICE_TYPE="iPhone 15" SIMULATOR_REUSE_SIMULATOR=False ./simulator_creator.py
Reuse simulator True

$ SIMULATOR_DEVICE_TYPE="iPhone 15" SIMULATOR_REUSE_SIMULATOR=Foo ./simulator_creator.py
Reuse simulator True

After

$ SIMULATOR_DEVICE_TYPE="iPhone 15" SIMULATOR_REUSE_SIMULATOR= ./simulator_creator.py
Reuse simulator True

$ SIMULATOR_DEVICE_TYPE="iPhone 15" SIMULATOR_REUSE_SIMULATOR=1 ./simulator_creator.py
Reuse simulator True

$ SIMULATOR_DEVICE_TYPE="iPhone 15" SIMULATOR_REUSE_SIMULATOR=True ./simulator_creator.py
Reuse simulator True

$ SIMULATOR_DEVICE_TYPE="iPhone 15" SIMULATOR_REUSE_SIMULATOR=0 ./simulator_creator.py
Reuse simulator False

$ SIMULATOR_DEVICE_TYPE="iPhone 15" SIMULATOR_REUSE_SIMULATOR=False ./simulator_creator.py
Reuse simulator False

$ SIMULATOR_DEVICE_TYPE="iPhone 15" SIMULATOR_REUSE_SIMULATOR=Foo ./simulator_creator.py
Reuse simulator True

I think this logic would be better if we explicitly checked SIMULATOR_REUSE_SIMULATOR for True or 1 and defaulted everything else to False, but I wasn't sure if that would mesh with the help text of "Toggle simulator reuse; default is True"

i.e.

    reuse_simulator_env = os.getenv("SIMULATOR_REUSE_SIMULATOR")
    reuse_simulator: bool = args.reuse_simulator or (
        reuse_simulator_env.lower() in ("1", "true") if reuse_simulator_env else False
    )

@keith keith added this to the 5.0.0 milestone Jun 23, 2026
@john-flanagan
john-flanagan force-pushed the jflan/resuse-simulator-fix branch from 91f8f43 to 9c850c7 Compare July 27, 2026 19:35
@adincebic

Copy link
Copy Markdown
Contributor

@john-flanagan @aaronsky @keith are all concerns addressed here? I would like to have this merged eventually. We maintain a local patch to specifically fix this issue.

@keith
keith force-pushed the jflan/resuse-simulator-fix branch from 9d150ac to fa77645 Compare October 26, 2026 23:43
@keith
keith enabled auto-merge (squash) October 26, 2026 23:43
@keith
keith merged commit 45c497b into bazelbuild:main Oct 27, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants