From fd16951ea21379d6ed37845d034ee2ce14d62bb6 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Thu, 5 Nov 2026 11:38:41 +0100 Subject: [PATCH] fixed extension test --- extension/CHANGELOG.md | 2 +- extension/test/projectinfo.test.ts | 6 ++++-- extension/test/rustanalyzer.test.ts | 6 ++++-- src/common/toolmeta.ts | 17 ++++++++++++----- test/unit/testurust.ts | 8 ++++++++ 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/extension/CHANGELOG.md b/extension/CHANGELOG.md index a36f3e00..c01b65e1 100644 --- a/extension/CHANGELOG.md +++ b/extension/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- Rust programs (`.rs`) build with urust on every platform it supports (NES, Atari 2600, C64, Atari 8-bit, Apple II, VIC-20, ZX Spectrum, and devel-6502). +- Rust programs (`.rs`) build with urust on every platform it supports (NES, Atari 2600/7800, C64, Atari 8-bit, Apple II, VIC-20, ZX Spectrum, ColecoVision, MSX, Game Boy, and devel-6502). Other Z80 platforms still send `.rs` to urust, but no longer get the Rust fallback language or the rust-analyzer settings, since the build would fail without a target. - Platform detection recognizes the `rs8::` module an urust program uses (`use rs8::nes::*;` picks the NES), and the ZX Spectrum maps to urust's `zx-spectrum` target. - `.rs` is treated as a shared extension: 8bitworkshop never claims it, never shows "No platform" for an unrelated Rust file, and leaves the `rust` language to your Rust extension. Without one, a built-in `Rust (urust)` grammar highlights the file inside a project. - New urust projects write `.vscode/settings.json` that turns off rust-analyzer's `cargo check` (urust has no Cargo target), its unresolved-name diagnostics (`rs8::*`, `reg!` and `#[reset]` can't resolve without a Cargo target; syntax and type errors stay), its Run/Debug lenses, and proc-macro expansion (the rs8 macros are markers; expanding `#[asm]`/`#[no_cross]` makes the proc-macro server exit with status 101), while keeping highlighting, hover and navigation. **8bitworkshop: Set Up rust-analyzer** does the same for an existing project, and setting a urust main file or accepting a detected project writes them automatically. diff --git a/extension/test/projectinfo.test.ts b/extension/test/projectinfo.test.ts index 22f2c061..ff831411 100644 --- a/extension/test/projectinfo.test.ts +++ b/extension/test/projectinfo.test.ts @@ -243,11 +243,13 @@ describe('languageFor', function () { }); it('offers the Rust fallback only on urust platforms', function () { - for (var platform of ['nes', 'vcs', 'c64', 'atari8-800', 'apple2', 'vic20', 'zx', 'devel-6502']) + for (var platform of ['nes', 'vcs', 'c64', 'atari8-800', 'apple2', 'vic20', 'zx', 'devel-6502', + 'coleco', 'msx', 'gb', 'atari7800']) assert.equal(rustLanguageFor('main.rs', platform), '8bws-rust', platform); assert.equal(languageFor('game.rs', 'nes'), '8bws-rust'); assert.equal(languageFor('GAME.RS', 'c64'), '8bws-rust'); - assert.equal(rustLanguageFor('main.rs', 'gb'), undefined); + // .rs selects urust on every Z80 platform, but cpc is not a urust target + assert.equal(rustLanguageFor('main.rs', 'cpc'), undefined); assert.equal(rustLanguageFor('main.rs', 'verilog'), undefined); assert.equal(rustLanguageFor('main.c', 'nes'), undefined); }); diff --git a/extension/test/rustanalyzer.test.ts b/extension/test/rustanalyzer.test.ts index 5d8e012c..67a7cbb3 100644 --- a/extension/test/rustanalyzer.test.ts +++ b/extension/test/rustanalyzer.test.ts @@ -5,11 +5,13 @@ import { describe('rust-analyzer settings', function () { it('recognizes a urust project by platform or tool', function () { - for (var platform of ['nes', 'vcs', 'c64', 'atari8-800', 'apple2', 'vic20', 'zx', 'devel-6502']) + for (var platform of ['nes', 'vcs', 'c64', 'atari8-800', 'apple2', 'vic20', 'zx', 'devel-6502', + 'coleco', 'msx', 'gb', 'atari7800']) assert.ok(isUrustProject(platform), platform); assert.ok(isUrustProject('nes', 'urust')); assert.ok(!isUrustProject('nes', 'cc65')); - assert.ok(!isUrustProject('gb'), 'gb has no urust target'); + assert.ok(!isUrustProject('cpc'), 'cpc has no urust target'); + assert.ok(!isUrustProject('verilog'), 'verilog has no urust target'); assert.ok(!isUrustProject(undefined)); }); diff --git a/src/common/toolmeta.ts b/src/common/toolmeta.ts index 5cbc0647..7dac49a8 100644 --- a/src/common/toolmeta.ts +++ b/src/common/toolmeta.ts @@ -1068,10 +1068,10 @@ export function getSkeletonName(tool: string): string { } /** - * urust's `--platform` names, keyed by the 8bitworkshop platform root (the id - * without a `.emulator` suffix or a `-specialization`). A root that isn't here - * has no urust target, even though .rs selects urust on every 6502/Z80 - * platform (see toolselect.ts). + * urust's `--platform` names that differ from the 8bitworkshop platform root + * (the id without a `.emulator` suffix or a `-specialization`). A root not in + * this map or in URUST_PASSTHROUGH_ROOTS has no urust target, even though .rs + * selects urust on every 6502/Z80 platform (see toolselect.ts). */ export const URUST_PLATFORM_NAMES: { [root: string]: string } = { 'devel': 'devel-6502', @@ -1079,9 +1079,16 @@ export const URUST_PLATFORM_NAMES: { [root: string]: string } = { 'coleco': 'colecovision' }; +/** Platform roots urust targets under their own name. */ +const URUST_PASSTHROUGH_ROOTS = new Set([ + 'nes', 'c64', 'atari8', 'vcs', 'apple2', 'vic20', 'atari7800', 'msx', 'gb', +]); + /** urust's `--platform` name for an 8bitworkshop platform id, if it has one. */ export function urustPlatformName(platform: string): string | undefined { - return URUST_PLATFORM_NAMES[platform.split(/[.-]/)[0]] || getRootBasePlatform(platform); + var root = getRootBasePlatform(platform); + if (URUST_PLATFORM_NAMES[root]) return URUST_PLATFORM_NAMES[root]; + return URUST_PASSTHROUGH_ROOTS.has(root) ? root : undefined; } /** diff --git a/test/unit/testurust.ts b/test/unit/testurust.ts index a068f90d..1a4739e1 100644 --- a/test/unit/testurust.ts +++ b/test/unit/testurust.ts @@ -130,6 +130,14 @@ describe('urust tool', function () { assert.strictEqual(urustPlatformName('vic20'), 'vic20'); // the Z80 backend names the whole computer, not the CPU assert.strictEqual(urustPlatformName('zx'), 'zx-spectrum'); + assert.strictEqual(urustPlatformName('coleco'), 'colecovision'); + // urust targets the MSX and Game Boy too + assert.strictEqual(urustPlatformName('msx'), 'msx'); + assert.strictEqual(urustPlatformName('gb'), 'gb'); + assert.strictEqual(urustPlatformName('atari7800'), 'atari7800'); + // .rs selects urust on every Z80 platform, but not every one is a target + assert.strictEqual(urustPlatformName('cpc'), undefined); + assert.strictEqual(urustPlatformName('verilog'), undefined); }); it('parses JSON diagnostics; end column only on a single line', function () {