mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-31 09:41:46 +00:00
183ee9caac
The manager emitted `logger.warn` four times during extraction and returned `null` for content that is valid but not updatable. A `rust-toolchain.toml` using `path` instead of `channel` is a legitimate file, yet it failed schema validation and produced a maintainer-facing warning. Per the logging guidance in `docs/development/best-practices.md`, WARN is consumed by metrics and error catching services, so it should not fire for user content Renovate simply cannot update. The manager guide also asks for a `skipReason` rather than silently dropping a dependency. The schema now accepts an optional `channel` and an optional `path`, and extraction reports: - `invalid-version` when a channel cannot be parsed - `path-dependency` when the file points at a local toolchain - `unspecified-version` when neither field is set `channel` takes precedence when both are present, since rustup rejects that combination and `channel` is the actionable field. Files that are not toolchain files at all still return `null`: TOML that does not parse, TOML without a `[toolchain]` table, and legacy plain text files that are empty or hold more than one line. The file pattern matches any file named `rust-toolchain`, so these are treated as false matches. All remaining logs are DEBUG.
157 lines
3.4 KiB
TypeScript
157 lines
3.4 KiB
TypeScript
import { codeBlock } from 'common-tags';
|
|
import { RustToolchain } from './schema.ts';
|
|
|
|
describe('modules/manager/rust-toolchain/schema', () => {
|
|
describe('RustToolchain', () => {
|
|
it('parses valid TOML with channel', () => {
|
|
const toml = codeBlock`
|
|
[toolchain]
|
|
channel = "1.89.1"
|
|
`;
|
|
|
|
const result = RustToolchain.parse(toml);
|
|
|
|
expect(result).toEqual({
|
|
toolchain: {
|
|
channel: '1.89.1',
|
|
},
|
|
});
|
|
});
|
|
|
|
it('parses TOML with additional fields', () => {
|
|
const toml = codeBlock`
|
|
[toolchain]
|
|
channel = "1.89.1"
|
|
components = ["rustfmt", "clippy"]
|
|
targets = ["wasm32-unknown-unknown"]
|
|
`;
|
|
|
|
const result = RustToolchain.parse(toml);
|
|
|
|
expect(result).toEqual({
|
|
toolchain: {
|
|
channel: '1.89.1',
|
|
},
|
|
});
|
|
});
|
|
|
|
it('throws error for invalid TOML', () => {
|
|
const toml = 'this is not valid toml [';
|
|
|
|
expect(() => RustToolchain.parse(toml)).toThrow('Invalid TOML');
|
|
});
|
|
|
|
it('throws error for missing toolchain section', () => {
|
|
const toml = codeBlock`
|
|
[other]
|
|
channel = "1.89.1"
|
|
`;
|
|
|
|
expect(() => RustToolchain.parse(toml)).toThrow(
|
|
'Invalid input: expected object, received undefined',
|
|
);
|
|
});
|
|
|
|
it('parses successfully when channel field is missing', () => {
|
|
const toml = codeBlock`
|
|
[toolchain]
|
|
components = ["rustfmt"]
|
|
`;
|
|
|
|
const result = RustToolchain.parse(toml);
|
|
|
|
expect(result).toEqual({
|
|
toolchain: {},
|
|
});
|
|
});
|
|
|
|
it('throws error for non-string channel', () => {
|
|
const toml = codeBlock`
|
|
[toolchain]
|
|
channel = 123
|
|
`;
|
|
|
|
expect(() => RustToolchain.parse(toml)).toThrow(
|
|
'Invalid input: expected string, received number',
|
|
);
|
|
});
|
|
|
|
it('parses successfully for empty channel', () => {
|
|
const toml = codeBlock`
|
|
[toolchain]
|
|
channel = ""
|
|
`;
|
|
|
|
const result = RustToolchain.parse(toml);
|
|
|
|
expect(result).toEqual({
|
|
toolchain: {
|
|
channel: '',
|
|
},
|
|
});
|
|
});
|
|
|
|
it('parses TOML with path', () => {
|
|
const toml = codeBlock`
|
|
[toolchain]
|
|
path = "/path/to/toolchain"
|
|
`;
|
|
|
|
const result = RustToolchain.parse(toml);
|
|
|
|
expect(result).toEqual({
|
|
toolchain: {
|
|
path: '/path/to/toolchain',
|
|
},
|
|
});
|
|
});
|
|
|
|
it('parses TOML with both channel and path', () => {
|
|
const toml = codeBlock`
|
|
[toolchain]
|
|
channel = "1.89.1"
|
|
path = "/path/to/toolchain"
|
|
`;
|
|
|
|
const result = RustToolchain.parse(toml);
|
|
|
|
expect(result).toEqual({
|
|
toolchain: {
|
|
channel: '1.89.1',
|
|
path: '/path/to/toolchain',
|
|
},
|
|
});
|
|
});
|
|
|
|
it('parses nightly channel', () => {
|
|
const toml = codeBlock`
|
|
[toolchain]
|
|
channel = "nightly-2025-10-12"
|
|
`;
|
|
|
|
const result = RustToolchain.parse(toml);
|
|
|
|
expect(result).toEqual({
|
|
toolchain: {
|
|
channel: 'nightly-2025-10-12',
|
|
},
|
|
});
|
|
});
|
|
|
|
it('parses stable keyword', () => {
|
|
const toml = codeBlock`
|
|
[toolchain]
|
|
channel = "stable"
|
|
`;
|
|
|
|
const result = RustToolchain.parse(toml);
|
|
|
|
expect(result).toEqual({
|
|
toolchain: {
|
|
channel: 'stable',
|
|
},
|
|
});
|
|
});
|
|
});
|
|
});
|