Skip to content

iOS testbed fails when the dir ~/Library/Developer/XCTestDevices is empty #135101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
joerick opened this issue Jun 3, 2025 · 3 comments
Closed
Assignees
Labels
3.13 bugs and security fixes 3.14 bugs and security fixes 3.15 new features, bugs and security fixes OS-ios type-bug An unexpected behavior, bug, or error

Comments

@joerick
Copy link
Contributor

joerick commented Jun 3, 2025

Bug report

Bug description:

iOS testbed run fails when the dir ~/Library/Developer/XCTestDevices is empty.

As seen in pypa/cibuildwheel#2443 .

The dir ~/Library/Developer/XCTestDevices is empty on machines that are clean, e.g. CI images.

The traceback is:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/private/var/folders/x8/34szswsn0zn1ktnx8k1v16qr0000gn/T/cibw-run-pztsyqge/cp313-ios_arm64_iphonesimulator/testbed/__main__.py", line 548, in <module>
    main()
    ~~~~^^
  File "/private/var/folders/x8/34szswsn0zn1ktnx8k1v16qr0000gn/T/cibw-run-pztsyqge/cp313-ios_arm64_iphonesimulator/testbed/__main__.py", line 530, in main
    asyncio.run(
    ~~~~~~~~~~~^
        run_testbed(
        ^^^^^^^^^^^^
    ...<3 lines>...
        )
        ^
    )
    ^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/private/var/folders/x8/34szswsn0zn1ktnx8k1v16qr0000gn/T/cibw-run-pztsyqge/cp313-ios_arm64_iphonesimulator/testbed/__main__.py", line 411, in run_testbed
    simulator = await select_simulator_device()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/var/folders/x8/34szswsn0zn1ktnx8k1v16qr0000gn/T/cibw-run-pztsyqge/cp313-ios_arm64_iphonesimulator/testbed/__main__.py", line 129, in select_simulator_device
    raw_json = await async_check_output(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
        "xcrun", "simctl", "--set", "testing", "list", "-j"
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/private/var/folders/x8/34szswsn0zn1ktnx8k1v16qr0000gn/T/cibw-run-pztsyqge/cp313-ios_arm64_iphonesimulator/testbed/__main__.py", line 118, in async_check_output
    raise subprocess.CalledProcessError(
    ...<4 lines>...
    )
subprocess.CalledProcessError: Command '('xcrun', 'simctl', '--set', 'testing', 'list', '-j')' returned non-zero exit status 1.

On a machine with empty ~/Library/Developer/XCTestDevices the above command returns:

$ xcrun simctl --set testing list -j
  
Using Parallel Testing Device Clones Device Set: '/Users/runner/Library/Developer/XCTestDevices'
Provided set path does not exist: /Users/runner/Library/Developer/XCTestDevices

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

@freakboy3742
Copy link
Contributor

Thanks for the report. This is one of those bugs that is infuriatingly difficult to reproduce, because as soon as you've run the simulator successfully, you never see the problem again. Thankfully it looks like this one might be reproducible on GitHub Actions.

I've previously fixed an issue related to this - #130388 - however, when I added support for autodetecting the default simulator in #133132, it looks like I've missed the corresponding error handling. Your proposed solution of removing the use of the testing set for device discovery makes sense; I'll check a couple of other edge cases to be sure.

@freakboy3742 freakboy3742 added 3.13 bugs and security fixes OS-ios 3.14 bugs and security fixes 3.15 new features, bugs and security fixes labels Jun 3, 2025
freakboy3742 pushed a commit that referenced this issue Jun 4, 2025
…ctl --set testing` (#135102)

On a fresh Xcode install (including some CI provider configurations), there is
no pre-existing testing set that can be used to identify simulator models. Use
the default device set to detect available models instead. Live testing 
simulators are still created in the testing set.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 4, 2025
…e `simctl --set testing` (pythonGH-135102)

On a fresh Xcode install (including some CI provider configurations), there is
no pre-existing testing set that can be used to identify simulator models. Use
the default device set to detect available models instead. Live testing
simulators are still created in the testing set.
(cherry picked from commit dba9de7)

Co-authored-by: Joe Rickerby <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 4, 2025
…e `simctl --set testing` (pythonGH-135102)

On a fresh Xcode install (including some CI provider configurations), there is
no pre-existing testing set that can be used to identify simulator models. Use
the default device set to detect available models instead. Live testing
simulators are still created in the testing set.
(cherry picked from commit dba9de7)

Co-authored-by: Joe Rickerby <[email protected]>
freakboy3742 pushed a commit that referenced this issue Jun 4, 2025
…se `simctl --set testing` (GH-135102) (#135114)

On a fresh Xcode install (including some CI provider configurations), there is
no pre-existing testing set that can be used to identify simulator models. Use
the default device set to detect available models instead. Live testing
simulators are still created in the testing set.
(cherry picked from commit dba9de7)

Co-authored-by: Joe Rickerby <[email protected]>
freakboy3742 pushed a commit that referenced this issue Jun 4, 2025
…se `simctl --set testing` (GH-135102) (#135113)

On a fresh Xcode install (including some CI provider configurations), there is
no pre-existing testing set that can be used to identify simulator models. Use
the default device set to detect available models instead. Live testing
simulators are still created in the testing set.
(cherry picked from commit dba9de7)

Co-authored-by: Joe Rickerby <[email protected]>
freakboy3742 pushed a commit to freakboy3742/cpython that referenced this issue Jun 4, 2025
…on't use `simctl --set testing` (pythonGH-135102) (python#135113)

On a fresh Xcode install (including some CI provider configurations), there is
no pre-existing testing set that can be used to identify simulator models. Use
the default device set to detect available models instead. Live testing
simulators are still created in the testing set.
(cherry picked from commit dba9de7)

Co-authored-by: Joe Rickerby <[email protected]>
freakboy3742 pushed a commit to freakboy3742/cpython that referenced this issue Jun 4, 2025
…on't use `simctl --set testing` (pythonGH-135102) (python#135114)

On a fresh Xcode install (including some CI provider configurations), there is
no pre-existing testing set that can be used to identify simulator models. Use
the default device set to detect available models instead. Live testing
simulators are still created in the testing set.
(cherry picked from commit dba9de7)

Co-authored-by: Joe Rickerby <[email protected]>
@joerick
Copy link
Contributor Author

joerick commented Jun 4, 2025

Thanks for merging!

This is one of those bugs that is infuriatingly difficult to reproduce, because as soon as you've run the simulator successfully, you never see the problem again.

I found that I could reproduce it by doing-

mv ~/Library/Developer/XCTestDevices ~/Library/Developer/XCTestDevices_bkup

Then I'd play around with it, then delete the dir and restore the bkup once done.

@freakboy3742
Copy link
Contributor

I found that I could reproduce it by doing-...

Good to know; my concern is whether that's actually "clean" from the perspective of Xcode - is the directory the only artefact that Xcode is relying on? It may well be... but it's impossible to know for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 bugs and security fixes 3.15 new features, bugs and security fixes OS-ios type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants