From be5654146555cd84db7e986463360a8c206cffd7 Mon Sep 17 00:00:00 2001 From: Waozi Date: Mon, 19 Oct 2026 20:01:01 -0300 Subject: [PATCH] Bring the tests up to date with today's app Astral Projection runs 40 minutes, habits store their coin level, package modules are generated under their package prefix, and the Elist link test names the modules the cells now use. Tests that load apps without Radio's playback get silent stand-ins. --- tests/astral_projection_content_test.py | 4 +-- tests/audio_first_cue_host.c | 5 ++++ tests/background_audio_stub.zi | 36 +++++++++++++++++++++++++ tests/daochi_native_zi_test.c | 6 +++++ tests/daochi_native_zi_test.py | 11 +++++++- tests/device_key_zi_test.py | 5 +++- tests/elist_screen_zi_test.sh | 7 ++++- tests/habit_form_behavior.zi | 1 + tests/session_results_behavior.zi | 1 + tests/storage_sql_behavior_test.py | 4 ++- 10 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 tests/background_audio_stub.zi diff --git a/tests/astral_projection_content_test.py b/tests/astral_projection_content_test.py index 86fee114b..7159a9a40 100644 --- a/tests/astral_projection_content_test.py +++ b/tests/astral_projection_content_test.py @@ -13,7 +13,7 @@ course = json.loads((folder / 'session.json').read_text()) config = json.loads((ROOT / 'design/astral-projection/narration.json').read_text()) keys = [cue['key'] for cue in course['cues']] assert keys == speech.narration_keys(config) -assert course['schema'] == 1 and course['duration'] == 900 +assert course['schema'] == 1 and course['duration'] == 2400 assert course['cues'][0]['second'] == 0 times = [cue['second'] for cue in course['cues']] + [course['duration']] assert all(a < b for a, b in zip(times, times[1:])) @@ -34,4 +34,4 @@ if receipt_path.is_file(): code, key = name.split('/') index = keys.index(key) assert clip['seconds'] + 1 < times[index + 1] - times[index], name -print('All eight guidance cues have complete translations in all 12 locales') +print(f'All {len(keys)} guidance cues of the 40-minute session have complete translations in all 12 locales') diff --git a/tests/audio_first_cue_host.c b/tests/audio_first_cue_host.c index 393be38a3..f172844f6 100644 --- a/tests/audio_first_cue_host.c +++ b/tests/audio_first_cue_host.c @@ -21,6 +21,11 @@ bool IsAudioDeviceReady(void) return ready; } +// Radio's background playback is not part of a cue's first frame. +void BackgroundAudioInterrupt(void) +{ +} + void CloseAudioDevice(void) { ready = false; diff --git a/tests/background_audio_stub.zi b/tests/background_audio_stub.zi new file mode 100644 index 000000000..c60f83fc0 --- /dev/null +++ b/tests/background_audio_stub.zi @@ -0,0 +1,36 @@ +// Radio's background playback for tests that load node apps without +// app/background_audio.zi: nothing plays. + +#program_export "BackgroundAudioStart" +StubBackgroundAudioStart :: (owner: s32, url: string) -> bool { + unused owner + unused url + return false +} + +#program_export "BackgroundAudioStop" +StubBackgroundAudioStop :: (owner: s32) { + unused owner +} + +#program_export "BackgroundAudioVolume" +StubBackgroundAudioVolume :: (owner: s32, percent: s32) -> bool { + unused owner + unused percent + return false +} + +#program_export "BackgroundAudioState" +StubBackgroundAudioState :: (owner: s32) -> s32 { + unused owner + return 0 +} + +#program_export "BackgroundAudioActive" +StubBackgroundAudioActive :: () -> bool { + return false +} + +#program_export "BackgroundAudioInterrupt" +StubBackgroundAudioInterrupt :: () { +} diff --git a/tests/daochi_native_zi_test.c b/tests/daochi_native_zi_test.c index d3e8ed467..eec14d710 100644 --- a/tests/daochi_native_zi_test.c +++ b/tests/daochi_native_zi_test.c @@ -90,6 +90,12 @@ String storage_get_setting_text(String key) return (String){0}; } +bool storage_setting_present(String key) +{ + (void)key; + return false; +} + void *sqlite3_db_mutex(void *database) { (void)database; diff --git a/tests/daochi_native_zi_test.py b/tests/daochi_native_zi_test.py index 028d7e034..f52428d6e 100644 --- a/tests/daochi_native_zi_test.py +++ b/tests/daochi_native_zi_test.py @@ -18,6 +18,15 @@ USER_ID = "a" * 64 NONCE = "c" * 64 + +def GeneratedSource(generated, name): + """A generated C file; package modules carry their package's prefix.""" + path = generated / name + if path.exists(): + return path + prefixed = sorted(path.parent.glob("p" + "[0-9a-f]" * 16 + "_" + path.name)) + return prefixed[0] if len(prefixed) == 1 else path + class Handler(BaseHTTPRequestHandler): friends_requests = 0 registrations = 0 @@ -137,7 +146,7 @@ with tempfile.TemporaryDirectory(prefix="inbe-daochi-native-") as temporary: f"-I{ROOT / 'build/packages/ziran/include'}", f"-I{generated}", f"-I{generated / 'storage'}", str(ROOT / "tests/daochi_native_zi_test.c"), - *(str(generated / source) for source in sources), + *(str(GeneratedSource(generated, source)) for source in sources), "-l:libcurl.so.4", "-o", str(executable), ], check=True) server = ThreadingHTTPServer(("127.0.0.1", 0), Handler) diff --git a/tests/device_key_zi_test.py b/tests/device_key_zi_test.py index 6c2ff24b6..8384b7bd1 100644 --- a/tests/device_key_zi_test.py +++ b/tests/device_key_zi_test.py @@ -4,6 +4,7 @@ from pathlib import Path import argparse import os +import re import subprocess import tempfile @@ -29,8 +30,10 @@ with tempfile.TemporaryDirectory(prefix="inbe-device-key-") as temporary: ], check=True) names = {"device_key_store.c", "device_key.c", "crypto.c", "keys.c", "byte_text_linux.c", "Oqs.c", "update_transport.c"} + # Package modules are generated under their package's prefix, + # such as p0123456789abcdef_Oqs.c. sources = sorted(str(path) for path in generated.rglob("*.c") - if path.name in names) + if path.name in names or re.sub(r"^p[0-9a-f]{16}_", "", path.name) in names) monocypher = ROOT / "build/packages/monocypher/src" subprocess.run([ args.emcc if args.wasm else os.environ.get("CC", "cc"), "-std=c11", "-O0", "-Wall", "-Wextra", diff --git a/tests/elist_screen_zi_test.sh b/tests/elist_screen_zi_test.sh index 43b270da2..4cf0407e8 100644 --- a/tests/elist_screen_zi_test.sh +++ b/tests/elist_screen_zi_test.sh @@ -38,7 +38,12 @@ mkdir -p "$work/c" "$work/c/sun_salutation_inventory.c" \ "$work/c/lists_visibility.c" "$work/c/bundle_host.c" \ "$work/c/hosted_values.c" "$work/c/widget_host.c" "$work/c/hosted_app.c" \ - "$root/build/ziran-toolchain/libziran.a" -lm \ + "$work/c/bundle_preload.c" "$work/c/thread_linux.c" "$work/c/catalog.c" \ + "$work/c/app_context_host.c" "$work/c/achievement_packages.c" \ + "$work/c/achievements.c" "$work/c/bundle_names.c" "$work/c/date_parse.c" \ + "$work/c/diary_wire.c" "$work/c/widget_codec.c" \ + "$work/c/achievement_records.c" "$work/c/number_text.c" "$work/c/text_buffer.c" \ + "$root/build/ziran-toolchain/libziran.a" -lm -lpthread \ -o "$work/test" env -u DISPLAY -u WAYLAND_DISPLAY "$work/test" "$root/build/inbe.zib" echo "Inbe elist screen Ziran/native test passed" diff --git a/tests/habit_form_behavior.zi b/tests/habit_form_behavior.zi index 1604a761f..12416f8f6 100644 --- a/tests/habit_form_behavior.zi +++ b/tests/habit_form_behavior.zi @@ -16,6 +16,7 @@ #import, file "../src/core/types.zi"; #import, file "../src/screens/habits/edit.zi"; #import, file "cells_test_fixture.zi"; +#import, file "background_audio_stub.zi"; using HabitSyncMode; diff --git a/tests/session_results_behavior.zi b/tests/session_results_behavior.zi index d321fbc88..7306788d2 100644 --- a/tests/session_results_behavior.zi +++ b/tests/session_results_behavior.zi @@ -18,6 +18,7 @@ #import, file "../src/practices/session_results.zi"; #import, file "../src/practices/meditation/meditation_practice.zi"; #import, file "../src/practices/meditation/meditation_session.zi"; +#import, file "background_audio_stub.zi"; c :: #system_library "c"; pause_microseconds :: (microseconds: u32) -> s32 #foreign c "usleep"; diff --git a/tests/storage_sql_behavior_test.py b/tests/storage_sql_behavior_test.py index 7761d7ef2..9e853b52c 100644 --- a/tests/storage_sql_behavior_test.py +++ b/tests/storage_sql_behavior_test.py @@ -62,7 +62,9 @@ db.executescript( span INTEGER NOT NULL DEFAULT 0, span_goal INTEGER NOT NULL DEFAULT 0, span_low INTEGER NOT NULL DEFAULT 0, - span_high INTEGER NOT NULL DEFAULT 0); + span_high INTEGER NOT NULL DEFAULT 0, + difficulty INTEGER NOT NULL DEFAULT 0, + coins_from INTEGER NOT NULL DEFAULT 0); CREATE TABLE habit_entries( id TEXT PRIMARY KEY, user_id TEXT, habit_id TEXT, local_date INTEGER, started_at INTEGER, ended_at INTEGER, answers TEXT,