fixed extension test

This commit is contained in:
Steven Hugg committed 2026-11-05 11:38:41 +01:00
1 parent 754521fc87
commit fd16951ea2
5 files changed
+29 -10

No files matched your search

+1 -1
View File
@@ -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.
+4 -2
View File
@@ -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);
});
+4 -2
View File
@@ -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));
});
+12 -5
View File
@@ -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;
}
/**
+8
View File
@@ -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 () {