Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to make sure -Wunused-crate-dependencies works with tests #72710

Merged
merged 1 commit into from
May 30, 2020

Conversation

jsgf
Copy link
Contributor

@jsgf jsgf commented May 28, 2020

Make sure code in #[test] blocks counts as a use of a crate.

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 28, 2020
@jsgf
Copy link
Contributor Author

jsgf commented May 28, 2020

This currently fails - I'm not sure why.

r? @petrochenkov

// edition:2018
// check-pass
// aux-crate:bar=bar.rs
// compiler-flags:--test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// compiler-flags:--test
// compile-flags:--test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, 🤦

@nikomatsakis
Copy link
Contributor

@bors delegate+

r=me once CI is happy

@bors
Copy link
Contributor

bors commented May 28, 2020

✌️ @jsgf can now approve this pull request

@nikomatsakis
Copy link
Contributor

Oh, I guess it was r? @petrochenkov :)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-8 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
##[section]Starting: Linux x86_64-gnu-llvm-8
##[section]Starting: Initialize job
Agent name: 'Azure Pipelines 63'
Agent machine name: 'fv-az619'
Current agent version: '2.168.2'
##[group]Operating System
16.04.6
LTS
LTS
##[endgroup]
##[group]Virtual Environment
Environment: ubuntu-16.04
Version: 20200517.1
Included Software: https://github.com/actions/virtual-environments/blob/ubuntu16/20200517.1/images/linux/Ubuntu1604-README.md
##[endgroup]
Agent running as: 'vsts'
Prepare build directory.
Set build variables.
Download all required tasks.
Download all required tasks.
Downloading task: Bash (3.163.2)
Checking job knob settings.
   Knob: AgentToolsDirectory = /opt/hostedtoolcache Source: ${AGENT_TOOLSDIRECTORY} 
   Knob: AgentPerflog = /home/vsts/perflog Source: ${VSTS_AGENT_PERFLOG} 
Start tracking orphan processes.
##[section]Finishing: Initialize job
##[section]Starting: Configure Job Name
==============================================================================
---
========================== Starting Command Output ===========================
[command]/bin/bash --noprofile --norc /home/vsts/work/_temp/69f1dea0-df3b-4fe3-9648-b8472b10ae66.sh

##[section]Finishing: Disable git automatic line ending conversion
##[section]Starting: Checkout rust-lang/rust@refs/pull/72710/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
---
##[command]git remote add origin https://github.com/rust-lang/rust
##[command]git config gc.auto 0
##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
##[command]git config --get-all http.proxy
##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/72710/merge:refs/remotes/pull/72710/merge
---
 ---> cb2676f08729
Step 5/8 : ENV RUST_CONFIGURE_ARGS       --build=x86_64-unknown-linux-gnu       --llvm-root=/usr/lib/llvm-8       --enable-llvm-link-shared       --set rust.thin-lto-import-instr-limit=10
 ---> Using cache
 ---> df25ce111862
Step 6/8 : ENV SCRIPT python2.7 ../x.py test --exclude src/tools/tidy &&            python2.7 ../x.py test src/test/mir-opt --pass=build                                   --target=armv5te-unknown-linux-gnueabi &&            python2.7 ../x.py test src/tools/tidy
 ---> 599b9ac96b27
Step 7/8 : ENV NO_DEBUG_ASSERTIONS=1
 ---> Using cache
 ---> 091087e35a36
---
   Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
   Compiling chalk-rust-ir v0.10.0
   Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
   Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
   Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
   Compiling chalk-solve v0.10.0
   Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
   Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
   Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
   Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
   Compiling chalk-rust-ir v0.10.0
   Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
   Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
   Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
   Compiling chalk-solve v0.10.0
   Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
   Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
   Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
..............................................................................i..................... 1800/10250
.................................................................................................... 1900/10250
.................................................................................................i.. 2000/10250
i................................................................................................... 2100/10250
.......................................................................................iiiii........ 2200/10250
.................................................................................................... 2400/10250
.................................................................................................... 2500/10250
.................................................................................................... 2600/10250
.................................................................................................... 2700/10250
---
...............i...............i.................................................................... 5200/10250
.................................................................................................... 5300/10250
...............................................................i.................................... 5400/10250
........................................................i........................................... 5500/10250
....................................................................ii.ii........i...i.............. 5600/10250
...........i........................................................................................ 5800/10250
...................i................................................................................ 5900/10250
........................................................................ii.......................... 6000/10250
...........i........................................................................................ 6100/10250
...........i........................................................................................ 6100/10250
.................................................................................................... 6200/10250
.................................................................................................... 6300/10250
.................................ii...i..ii...........i............................................. 6400/10250
.................................................................................................... 6600/10250
.................................................................................................... 6700/10250
.................................................................................................... 6700/10250
..................................................................i..ii............................. 6800/10250
.................................................................................................... 7000/10250
.................................................................................................... 7100/10250
....................i............................................................................... 7200/10250
.................................................................................................... 7300/10250
---
.................................................................................................... 8200/10250
.................................................................................................... 8300/10250
.......................................................i............................................ 8400/10250
.................................................................................................... 8500/10250
.........iiiiii.iiiiii.i............................................................................ 8600/10250
.................................................................................................... 8800/10250
.................................................................................................... 8900/10250
.................................................................................................... 9000/10250
.................................................................................................... 9100/10250
---
---- [ui] ui/unused-crate-deps/test-use-ok.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit code: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/unused-crate-deps/test-use-ok.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/unused-crate-deps/test-use-ok" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/unused-crate-deps/test-use-ok/auxiliary" "--extern" "bar=/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/unused-crate-deps/test-use-ok/auxiliary/libbar.so"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
error: external crate `bar` unused in `test_use_ok`: remove the dependency or add `use bar as _;`
  --> /checkout/src/test/ui/unused-crate-deps/test-use-ok.rs:8:1
LL | #![deny(unused_crate_dependencies)]
   | ^
   |
note: the lint level is defined here
---
thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:348:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-8/bin/FileCheck" "--nodejs" "/usr/bin/node" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "8.0.0" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"


failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
Build completed unsuccessfully in 1:03:40
Build completed unsuccessfully in 1:03:40
== clock drift check ==
  local time: Thu May 28 22:50:07 UTC 2020
  network time: Thu, 28 May 2020 22:50:07 GMT
== end clock drift check ==

##[error]Bash exited with code '1'.
##[section]Finishing: Run build
##[section]Starting: Checkout rust-lang/rust@refs/pull/72710/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
Author       : Microsoft
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
==============================================================================
Cleaning any cached credential from repository: rust-lang/rust (GitHub)
##[section]Finishing: Checkout rust-lang/rust@refs/pull/72710/merge to s
Cleaning up task key
Start cleaning up orphan processes.
Terminate orphan process: pid (6656) (python)
##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

Make sure code in `#[test]` blocks counts as a use of a crate.
@jsgf
Copy link
Contributor Author

jsgf commented May 29, 2020

@bors r+

@bors
Copy link
Contributor

bors commented May 29, 2020

📌 Commit ce81d15 has been approved by jsgf

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 29, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 29, 2020
Add test to make sure -Wunused-crate-dependencies works with tests

Make sure code in `#[test]` blocks counts as a use of a crate.
bors added a commit to rust-lang-ci/rust that referenced this pull request May 30, 2020
Rollup of 10 pull requests

Successful merges:

 - rust-lang#72033 (Update RELEASES.md for 1.44.0)
 - rust-lang#72162 (Add Extend::{extend_one,extend_reserve})
 - rust-lang#72419 (Miri read_discriminant: return a scalar instead of raw underlying bytes)
 - rust-lang#72621 (Don't bail out of trait selection when predicate references an error)
 - rust-lang#72677 (Fix diagnostics for `@ ..` binding pattern in tuples and tuple structs)
 - rust-lang#72710 (Add test to make sure -Wunused-crate-dependencies works with tests)
 - rust-lang#72724 (Revert recursive `TokenKind::Interpolated` expansion for now)
 - rust-lang#72741 (Remove unused mut from long-linker-command-lines test)
 - rust-lang#72750 (Remove remaining calls to `as_local_node_id`)
 - rust-lang#72752 (remove mk_bool)

Failed merges:

r? @ghost
@bors bors merged commit 875c6b2 into rust-lang:master May 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants