unsloth/tests/python/test_whisper_source_build_root.py
Nilay e1653bcd1d
Some checks are pending
Kaggle T4 Unsloth GPU CI / Unsloth GPU smoke (push) Blocked by required conditions
Core / Core (HF=default + TRL=default) (push) Waiting to run
Core / Core (HF=4.57.6 + TRL<1) (push) Waiting to run
Core / Core (HF=latest + TRL=latest) (push) Waiting to run
Core / llama.cpp build + smoke (push) Waiting to run
Cross-platform parity / parity (ubuntu-latest) (push) Waiting to run
Cross-platform parity / parity (windows-latest) (push) Waiting to run
Kaggle T4 Notebook CI / gate (push) Waiting to run
Kaggle T4 Notebook CI / T4 smoke (push) Blocked by required conditions
Kaggle T4 Unsloth GPU CI / gate (push) Waiting to run
Lint CI / Source lint (Python + shell + YAML + JSON + safety nets) (push) Waiting to run
Local Agent Guides CI / connection (claude, stable) (push) Waiting to run
Local Agent Guides CI / connection (codex, stable) (push) Waiting to run
Local Agent Guides CI / connection (hermes, stable) (push) Waiting to run
Local Agent Guides CI / connection (openclaw, stable) (push) Waiting to run
Local Agent Guides CI / connection (opencode, stable) (push) Waiting to run
Local Agent Guides CI / connection (opencode, v2) (push) Waiting to run
Local Agent Guides CI / connection (pi, stable) (push) Waiting to run
Local Agent Guides CI / file-edit (claude) (push) Waiting to run
Local Agent Guides CI / file-edit (codex) (push) Waiting to run
Local Agent Guides CI / file-edit (hermes) (push) Waiting to run
Local Agent Guides CI / file-edit (openclaw) (push) Waiting to run
Local Agent Guides CI / file-edit (opencode) (push) Waiting to run
Local Agent Guides CI / file-edit (pi) (push) Waiting to run
Local Agent Guides CI / resume (claude) (push) Waiting to run
Local Agent Guides CI / resume (codex) (push) Waiting to run
Local Agent Guides CI / resume (opencode) (push) Waiting to run
Local Agent Guides CI / resume (pi) (push) Waiting to run
Local Agent Guides CI / prompt-cache (gemma-3-270m) (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Security audit / advisory audit (pip + npm + cargo) (push) Waiting to run
Security audit / pip scan-packages :: extras (push) Waiting to run
Security audit / pip scan-packages :: studio (push) Waiting to run
Security audit / pip scan-packages :: hf-stack (push) Waiting to run
Security audit / npm scan-packages (Unsloth frontend tarballs) (push) Waiting to run
Security audit / npm provenance + new install-script diff (push) Waiting to run
Unsloth API CI / Unsloth API & Auth Tests (push) Waiting to run
Backend CI / (Python 3.11) (push) Waiting to run
Backend CI / (Python 3.13) (push) Waiting to run
Backend CI / Repo tests (CPU) (push) Waiting to run
Unsloth export capability / capability (windows-latest) (push) Waiting to run
Frontend CI / Frontend build + bundle sanity (push) Waiting to run
Frontend CI / Frontend unit tests (Windows) (push) Waiting to run
Unsloth GGUF CI / GGUF inference smoke (API, tools, vision) (push) Waiting to run
Mac Unsloth Install Matrix CI / Install + load (macos-15) (push) Waiting to run
Mac Unsloth Install Matrix CI / Install + load (macos-26) (push) Waiting to run
Mac Unsloth Install Matrix CI / Install + load (macos-15-intel) (push) Waiting to run
Mac Unsloth Install Matrix CI / Install + load (macos-26-intel) (push) Waiting to run
Mac Unsloth UI + API + Update + Inference CI / Chat UI, API, Update and GGUF inference (push) Waiting to run
Unsloth Tauri CI / Tauri Linux debug build (no codesign) (push) Waiting to run
Unsloth Tauri CI / Rust unit tests (windows) (push) Waiting to run
Unsloth Tauri CI / Rust unit tests (macos) (push) Waiting to run
Unsloth UI CI / Chat UI Tests (extra) (push) Waiting to run
Unsloth UI CI / Chat UI Tests (picker) (push) Waiting to run
Unsloth UI CI / Chat UI Tests (banner) (push) Waiting to run
Unsloth UI CI / Chat UI Tests (chat) (push) Waiting to run
Unsloth UI CI / Loaded-models indicator (cross-browser) (push) Waiting to run
Unsloth Update CI / Unsloth Updating Tests (push) Waiting to run
Windows Unsloth API CI / Unsloth API & Auth Tests (push) Waiting to run
Windows Unsloth GGUF CI / GGUF inference smoke (API, tools, vision) (push) Waiting to run
Windows Unsloth GGUF CI / Unsloth install + inference without Visual Studio (push) Waiting to run
Windows Unsloth GGUF CI / real-VS detection (VS 2022) (push) Waiting to run
Windows Unsloth GGUF CI / real-VS detection + VC++ round-trip (VS 2026) (push) Waiting to run
Windows Unsloth GGUF CI / setup.ps1 units, no-VS resolve, VC++ round-trip (windows-latest) (push) Waiting to run
Windows Unsloth UI CI / Chat UI Tests (push) Waiting to run
Windows Unsloth Update CI / Unsloth Updating Tests (push) Waiting to run
studiobench CI / Selftests, lint and the single-file build (push) Waiting to run
studiobench CI / Real-path session, every action ran (push) Waiting to run
Wheel CI / Wheel build + content sanity + import smoke (push) Waiting to run
Windows Application Control CI / installer survives a denied unsloth.exe (push) Waiting to run
Workflow trigger lint / workflow-trigger lint (pull_request_target / cache-poisoning) (push) Waiting to run
Studio: update in the background and restart when ready (#9890)
* Studio: prepare desktop updates in the background and swap them in at restart

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: keep a staged update off the live install and add the missing locale keys

* Studio: relocate the staged launcher, bound the idle wait and make rollback exact

* Studio: stop the staged-update tests racing their own background deleters

* Studio: --stage default is a truthy typer sentinel off the CLI

* Studio: keep the staged update inside the gate and rename invariants the PR moved

* Studio: bound the health probe and keep the rollback while the runtime is in use

* Studio: gate the staged clone, reject reused pids, and keep the bundle off the heap

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: evict staged-only entries when undoing activation, and clean the bundle after single-instance

* Studio: read startup markers, corroborate the bare pid, and gate the staged backend version

* isolate staged python execution

* match adopted stages to update versions

* retain verified desktop update bundles

* adopt active desktop bundle downloads

* discard withdrawn staged updates

* journal staged runtime activation

* isolate staged native helpers

* serialize posix runtime updates

* stop staged update process groups

* verify staged backend before confirmation

* roll back failed staged backends

* label classic update fallback accurately

* tighten updater comments

* relaunch after macos staged rollback

* finalize mixed-version staged launchers

* transfer backend runtime gate ownership

* retry transient staged backend probes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* scrub stale backend gate handoffs

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* persist failed version before rollback completion

* preserve staged launcher through verification

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* wait for staged backend warmup

* keep staged helper builds isolated

* preserve staged ownership after app exit

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* avoid windows updater dll locks

* restore foreground git bootstrap

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maheswar Kumar <110882203+mahiatlinux@users.noreply.github.com>
2026-08-29 20:11:35 +12:00

59 lines
1.8 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.
from __future__ import annotations
import os
import subprocess
from pathlib import Path
import pytest
REPO_ROOT = Path(__file__).resolve().parents[2]
BUILD_SCRIPT = REPO_ROOT / "scripts" / "build_whisper_cpp.sh"
@pytest.mark.skipif(os.name == "nt", reason = "the source builder is POSIX-only")
def test_source_build_uses_the_staged_managed_root(tmp_path):
tool_dir = tmp_path / "bin"
tool_dir.mkdir()
git = tool_dir / "git"
git.write_text(
"#!/bin/sh\n"
"for argument do destination=$argument; done\n"
'mkdir -p "$destination/.git"\n',
encoding = "utf-8",
)
cmake = tool_dir / "cmake"
cmake.write_text(
"#!/bin/sh\n"
'if [ "$1" = "-S" ]; then\n'
" while [ $# -gt 0 ]; do\n"
' if [ "$1" = "-B" ]; then shift; build=$1; break; fi\n'
" shift\n"
" done\n"
' mkdir -p "$build/bin"\n'
" printf '#!/bin/sh\\nexit 0\\n' > \"$build/bin/whisper-server\"\n"
' chmod +x "$build/bin/whisper-server"\n'
"fi\n",
encoding = "utf-8",
)
git.chmod(0o755)
cmake.chmod(0o755)
live_home = tmp_path / "live-home"
stage_root = tmp_path / "stage"
env = {
**os.environ,
"HOME": str(live_home),
"PATH": f"{tool_dir}{os.pathsep}{os.environ['PATH']}",
"UNSLOTH_HOME": str(stage_root),
}
env.pop("UNSLOTH_STUDIO_HOME", None)
env.pop("STUDIO_HOME", None)
subprocess.run(["sh", str(BUILD_SCRIPT)], env = env, check = True, capture_output = True)
assert (stage_root / "whisper.cpp" / "build" / "bin" / "whisper-server").is_file()
assert not (live_home / ".unsloth" / "whisper.cpp").exists()