Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
Fail the engine tool job on test errors and repair its test setup
thehobbit856cd775347249
diff --git a/.github/scripts/tests/test_engine_test_job.py b/.github/scripts/tests/test_engine_test_job.pynew file mode 100644index 00000000..d7d7ba06--- /dev/null+++ b/.github/scripts/tests/test_engine_test_job.py@@ -0,0 +1,72 @@+"""Exercise the workflow's real test loop with synthetic passing and failing files."""+import os+from pathlib import Path+import subprocess+import sys+import tempfile+import unittest++WORKFLOW = Path(__file__).resolve().parents[2] / 'workflows/tests.yml'+++def test_step():+ lines = WORKFLOW.read_text().splitlines()+ start = next(i for i, line in enumerate(lines) if line == ' - name: Run the test files')+ start = next(i for i in range(start, len(lines)) if lines[i] == ' run: |') + 1+ end = next(i for i in range(start, len(lines)) if lines[i] and not lines[i].startswith(' '))+ return '\n'.join(line[10:] for line in lines[start:end])+++class EngineTestJob(unittest.TestCase):+ def run_job(self, first_test, broken_log=False):+ with tempfile.TemporaryDirectory(prefix='nx-tool-tests-') as tmp:+ root = Path(tmp)+ bin_dir = root / 'bin'+ bin_dir.mkdir()+ (bin_dir / 'python').symlink_to(sys.executable)+ for directory, body in (+ ('dm/tools/tests', first_test),+ ('dm/ios/tests', 'self.assertTrue(True)'),+ ('dm/gfx/tests', 'self.assertTrue(True)'),+ ):+ folder = root / directory+ folder.mkdir(parents=True)+ # Distinct names match the real loop's individual log files.+ name = 'test_' + directory.split('/')[1] + '.py'+ (folder / name).write_text('import unittest\nclass Fixture(unittest.TestCase):\n def test_result(self): ' + body + '\n')+ if broken_log:+ (root / 'logs/test_tools.py.log').mkdir(parents=True)+ # The job-level working-directory defaults leave the runner using bash -e.+ # Failure propagation must remain correct with that actual CI invocation.+ result = subprocess.run(['/bin/bash', '-e', '-c', test_step()], cwd=root,+ env=dict(os.environ, PATH=str(bin_dir) + os.pathsep + os.environ['PATH']),+ capture_output=True, text=True)+ logs = {p.name: p.read_text() for p in (root / 'logs').iterdir() if p.is_file()}+ return result, logs++ def test_a_failed_file_fails_the_job_and_later_files_still_run(self):+ result, logs = self.run_job('self.fail("intentional regression fixture")')+ self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr)+ self.assertIn('intentional regression fixture', result.stdout)+ self.assertIn('::error::dm/tools/tests/test_tools.py failed', result.stdout)+ self.assertIn('OK', logs['test_gfx.py.log'])++ def test_all_passing_files_succeed_and_keep_their_logs(self):+ result, logs = self.run_job('self.assertTrue(True)')+ self.assertEqual(result.returncode, 0, result.stdout + result.stderr)+ self.assertEqual(set(logs), {'test_tools.py.log', 'test_ios.py.log', 'test_gfx.py.log'})+ self.assertTrue(all('OK' in text for text in logs.values()))++ def test_a_test_error_also_fails_the_job(self):+ result, _ = self.run_job('raise RuntimeError("intentional test error")')+ self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr)+ self.assertIn('intentional test error', result.stdout)++ def test_a_log_write_failure_is_not_reported_as_success(self):+ result, logs = self.run_job('self.assertTrue(True)', broken_log=True)+ self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr)+ self.assertIn('OK', logs['test_gfx.py.log'])+++if __name__ == '__main__':+ unittest.main()diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex ad2f156e..8c786760 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -151,11 +151,22 @@ jobs:env:HOMEBREW_NO_AUTO_UPDATE: 1run: brew install spirv-tools+ - name: Metal compiler for the synthetic shader tests (no GPU needed)+ run: |+ if ! xcrun -sdk macosx metal --version; then+ xcodebuild -downloadComponent MetalToolchain+ fi+ xcrun -sdk macosx metal --version+ xcrun -sdk iphoneos metal --version- name: Run the test filesenv:DM_GAME: ${{ env.GAME }} # test_tbdr_budget runs a tool that needs a profileDMSH_TEST_XLATE: ${{ github.workspace }}/engine/dm/gfx/tools/dmsh_xlate_bin/dmsh_xlate+ DM_SHELL_PACKAGE: ${{ github.workspace }}/frontend-iosrun: |+ # Job-level run defaults can leave this step on bash -e, without pipefail.+ # Keep every file's status through tee and still run the rest for diagnostics.+ set -o pipefailmkdir -p logsfailed=0for f in dm/tools/tests/test_*.py dm/ios/tests/test_*.py dm/gfx/tests/test_*.py; do@@ -434,6 +445,8 @@ jobs:# Route C M2: build_shell.sh generates and builds the shell (host, frontend-ios package, a synthetic framework embedded and not# linked). make_ext_font.py needs fontTools, which only this step installs- name: The shell app embeds a game framework and builds (route C M2)+ env:+ DM_SHELL_PACKAGE: ${{ github.workspace }}/frontend-iosif: ${{ !cancelled() && steps.sync.outcome == 'success' }}run: |python3 -m pip install --user --break-system-packages fonttools > /dev/nulldiff --git a/patches/0078-document-the-fork-touch-controls-so-environment.patch b/patches/0078-document-the-fork-touch-controls-so-environment.patchnew file mode 100644index 00000000..4603e7d8--- /dev/null+++ b/patches/0078-document-the-fork-touch-controls-so-environment.patch@@ -0,0 +1,30 @@+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001+From: thehobbit85 <[email protected]>+Date: Wed, 4 Nov 2026 20:44:33 -0800+Subject: [PATCH] Document the fork touch controls so environment validation+ passes++Upstream-Status: fork-only+Reason: The fork touch-control patches add four environment settings without table rows, which makes the Tool tests job fail once it preserves test exit status+Issue: LNPANDY/NX2Apple#690++---+ docs/env_switches.tsv | 4 +++++ 1 file changed, 4 insertions(+)++diff --git a/docs/env_switches.tsv b/docs/env_switches.tsv+index 772479e..6d37d61 100644+--- a/docs/env_switches.tsv++++ b/docs/env_switches.tsv+@@ -358,7 +358,11 @@ DM_THERMAL_CAP switch `0` turns off the thermal cap, which holds the frame step+ DM_THR diagnostic `=1` logs each SVC (except `SleepThread`) with its first four arguments, and each `CreateThread` with entry, stack, priority and core+ DM_THRCPU diagnostic `=<tsv path>[,<seconds>]` writes each thread's CPU time (100% = one core) and the total every interval (default 10 s); on iOS a relative path is under `Documents`+ DM_TOUCH_HAPTICS player `0` turns off the light haptic tap when a touch control is pressed (on by default); launcher setting++DM_TOUCH_HINT player Localized words for the iOS right-stick hint, shown once per launch when the 3D layout has room and no controller is connected. Empty disables the hint++DM_TOUCH_LAYOUT player The player's per-layout touch-control arrangement, encoded by the shell's touch layout editor. Invalid values keep the built-in positions+ DM_TOUCH_LOG diagnostic `=1` logs each touch-screen read with touch points (sample, finger, position, attributes) and each gesture entry, up to 500 lines++DM_TOUCH_SIZE player iOS touch-control size: small, medium (default) or large. Controls move toward medium when the requested size does not fit++DM_TOUCH_STICK player iOS left touch-stick position: corner (default), higher or inward+ DM_UDC_SELFTEST diagnostic `=1` runs a start-up check of DontCare load and store on private depth-stencil and RGBA8 textures (clear, Load + DontCare, read back) and logs one result line+ DM_UE_SHADERS path Folder of the Unreal shader code archives decoded by `uepak.py`, for `shader_split.py` (default `ue_shaders` beside the RomFS); needed when the RomFS has Unreal paks+ DM_UE_TEXTURE_POOL switch Megabytes Unreal's texture streaming pool (`r.Streaming.PoolSize`) is raised to, overriding the profile's `ue_texture_pool`; `0` keeps the game's own pool. On iOS only this switch turns it on (`Documents/env.txt`)diff --git a/patches/series b/patches/seriesindex 8a2fffaf..5e4f4158 100644--- a/patches/series+++ b/patches/series@@ -45,3 +45,4 @@0075-front-mac-hide-the-pointer-before-the-game-takes.patch0076-host-read-embedded-sections-from-the-image-that.patch0077-ios-shell-link-the-host-into-each-game-s-framewo.patch+0078-document-the-fork-touch-controls-so-environment.patch