diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-12-02 10:43:37 +0100 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-12-15 13:26:55 -0800 |
| commit | 499015e6ee9b9f47c214b485e5b97f4addb64129 (patch) | |
| tree | 89c0a698406b0ea41ed6ac2ef46b852a8ab66da6 /test cases | |
| parent | 5f930d4b53145b9b65e10bfd0d36a9ca91b5297c (diff) | |
| download | meson-499015e6ee9b9f47c214b485e5b97f4addb64129.tar.gz | |
cargo: convert TOMLDecodeError or toml2json errors to a MesonException
Avoid getting a raw exception, instead use a (subclass of) MesonException
that is printed in the usual "FILE:LINE:COLUMN: MESSAGE" format.
Fixes: #15023
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'test cases')
4 files changed, 38 insertions, 0 deletions
diff --git a/test cases/failing/136 cargo toml error/meson.build b/test cases/failing/136 cargo toml error/meson.build new file mode 100644 index 000000000..6efaab2c5 --- /dev/null +++ b/test cases/failing/136 cargo toml error/meson.build @@ -0,0 +1,19 @@ +project('cargo-toml-error', 'c') + +if not add_languages('rust', required: false) + error('MESON_SKIP_TEST Rust not present, required for Cargo subprojets') +endif + +# Check if we have tomllib/tomli (not toml2json) +python = find_program('python3', 'python') +result = run_command(python, '-c', 'import tomllib', check: false) +if result.returncode() != 0 + result = run_command(python, '-c', 'import tomli', check: false) + if result.returncode() != 0 + # Skip test if using toml2json - error format will be different + error('MESON_SKIP_TEST toml2json in use, skipping test') + endif +endif + +# This should trigger a CargoTomlError with proper location info +foo_dep = dependency('foo-0') diff --git a/test cases/failing/136 cargo toml error/subprojects/foo-0-rs.wrap b/test cases/failing/136 cargo toml error/subprojects/foo-0-rs.wrap new file mode 100644 index 000000000..c39970188 --- /dev/null +++ b/test cases/failing/136 cargo toml error/subprojects/foo-0-rs.wrap @@ -0,0 +1,5 @@ +[wrap-file] +method = cargo + +[provide] +dependency_names = foo-0 diff --git a/test cases/failing/136 cargo toml error/subprojects/foo-0-rs/Cargo.toml b/test cases/failing/136 cargo toml error/subprojects/foo-0-rs/Cargo.toml new file mode 100644 index 000000000..2f2d7a681 --- /dev/null +++ b/test cases/failing/136 cargo toml error/subprojects/foo-0-rs/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "foo" +version = "0.0.1" +edition = "2021" +# This creates a TOML decode error: duplicate key +name = "bar"
\ No newline at end of file diff --git a/test cases/failing/136 cargo toml error/test.json b/test cases/failing/136 cargo toml error/test.json new file mode 100644 index 000000000..480cf64d5 --- /dev/null +++ b/test cases/failing/136 cargo toml error/test.json @@ -0,0 +1,8 @@ +{ + "stdout": [ + { + "match": "re", + "line": "test cases/failing/136 cargo toml error/(subprojects/foo-0-rs/Cargo\\.toml:6:13|meson\\.build:19:10): ERROR: Cannot overwrite a value( \\(at.*)?" + } + ] +} |
