diff options
| author | David Wood <david.wood@huawei.com> | 2024-01-31 11:44:09 +0000 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2024-02-21 14:37:13 +0000 |
| commit | a2aa9672f62c57c3701938982143c49404e8dff2 (patch) | |
| tree | 7aa6af3117b27c6d272b4ada4d5c84089cd488da /tests/ui/compiletest-self-test | |
| parent | 29f87ade9d78d233e85ef6ca2d6153d0d4fd38d6 (diff) | |
| download | rust-a2aa9672f62c57c3701938982143c49404e8dff2.tar.gz rust-a2aa9672f62c57c3701938982143c49404e8dff2.zip | |
compiletest: support auxiliaries with auxiliaries
To test behaviour that depends on the extern options of intermediate
crates, compiletest auxiliaries must have their own auxiliaries.
Auxiliary compilation previously did not trigger compilation of any
auxiliaries in the auxiliary's headers. In addition, those auxiliaries
would need to be in an `auxiliary/auxiliary` directory, which is
unnecessary and makes some crate graphs harder to write tests for,
such as when A depends on B and C, and B depends on C.
For a test `tests/ui/$path/root.rs`, with the following crate graph:
```
root
|-- grandparent
`-- parent
`-- grandparent
```
then the intermediate outputs from compiletest will be:
```
build/$target/test/ui/$path/
|-- auxiliary
| |-- libgrandparent.dylib
| |-- libparent.dylib
| |-- grandparent
| | |-- grandparent.err
| | `-- grandparent.out
| `-- parent
| |-- parent.err
| `-- parent.out
|-- libroot.rmeta
|-- root.err
`-- root.out
```
Signed-off-by: David Wood <david@davidtw.co>
Diffstat (limited to 'tests/ui/compiletest-self-test')
| -rw-r--r-- | tests/ui/compiletest-self-test/aux-aux.rs | 14 | ||||
| -rw-r--r-- | tests/ui/compiletest-self-test/auxiliary/aux_aux_bar.rs | 3 | ||||
| -rw-r--r-- | tests/ui/compiletest-self-test/auxiliary/aux_aux_foo.rs | 4 |
3 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/compiletest-self-test/aux-aux.rs b/tests/ui/compiletest-self-test/aux-aux.rs new file mode 100644 index 00000000000..c87905ff775 --- /dev/null +++ b/tests/ui/compiletest-self-test/aux-aux.rs @@ -0,0 +1,14 @@ +//@ aux-crate: aux_aux_foo=aux_aux_foo.rs +//@ aux-crate: aux_aux_bar=aux_aux_bar.rs +//@ edition: 2021 +//@ compile-flags: --crate-type lib +//@ check-pass + +use aux_aux_foo::Bar as IndirectBar; +use aux_aux_bar::Bar as DirectBar; + +fn foo(x: IndirectBar) {} + +fn main() { + foo(DirectBar); +} diff --git a/tests/ui/compiletest-self-test/auxiliary/aux_aux_bar.rs b/tests/ui/compiletest-self-test/auxiliary/aux_aux_bar.rs new file mode 100644 index 00000000000..eefcc270c38 --- /dev/null +++ b/tests/ui/compiletest-self-test/auxiliary/aux_aux_bar.rs @@ -0,0 +1,3 @@ +//@ edition: 2021 + +pub struct Bar; diff --git a/tests/ui/compiletest-self-test/auxiliary/aux_aux_foo.rs b/tests/ui/compiletest-self-test/auxiliary/aux_aux_foo.rs new file mode 100644 index 00000000000..f96c6bb0b27 --- /dev/null +++ b/tests/ui/compiletest-self-test/auxiliary/aux_aux_foo.rs @@ -0,0 +1,4 @@ +//@ aux-crate: aux_aux_bar=aux_aux_bar.rs +//@ edition: 2021 + +pub use aux_aux_bar::Bar; |
