Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
The #[test] attribute
Search
Daichi Mukai
July 20, 2019
Technology
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
The #[test] attribute
How to generate test binaries by #[test] attributes in Rust
Daichi Mukai
July 20, 2019
Other Decks in Technology
See All in Technology
脆弱性診断って、何をしているの? 〜弱点を見つけて、会社の改善につなげるまで〜
keeg
0
920
自作バイナリを動かす「入口」8選
puhitaku
2
1.3k
QA4AI 2026-Oct 生成AI時代の品質保証
tokuty
1
860
Refining Active Record
shugo
0
160
"優秀な誰か"の下位互換にならないために
yut0naga1_fa
1
1.8k
『SAR衛星データ解析入門』のご紹介とその応用
syuchimu
0
120
初海外で注意すべきこと12選!!!安全快適なre:invent生活にするために
yuuuuuuu168
1
160
Rustuna: Rustによる高速なOptuna実装
pfn
PRO
0
190
Benchmarking Disaggregated Serving on vLLM + Dynamo with a Real Coding-Agent Workload
nttcom
1
190
日本語に強いオープンな大規模言語モデル「LLM-jp」
odashi
4
1.1k
分析AIエージェントを育てる、動く環境を育てる
codatum
1
1.1k
DGX Spark でどこまでハッキングができるのか?
kash1064
3
1.3k
Featured
See All Featured
WCS-LA-2024
lcolladotor
0
890
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
450
We Are The Robots
honzajavorek
0
400
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
940
YesSQL, Process and Tooling at Scale
rocio
174
15k
WENDY [Excerpt]
tessaabrams
14
40k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
850
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
750
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
580
Claude Code のすすめ
schroneko
67
230k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Transcript
The The #[test] #[test] attribute attribute
//! test.rs #[test] fn my_test() { assert!(2 + 2 ==
4); }
$ rustc --test test.rs $ ./test running 1 test test
my_test ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0
どういう仕組み︖ どういう仕組み︖ $ rustc --emit=asm --test rust.rs $ wc -l
test.rs 4 test.rs $ wc -l test.s 2406 test.s
HIR HIR Rust のコンパイル︓ 1. Rust source 2. HIR 3.
MIR 4. LLVM IR 5. Machine code HIR を⾒てみる $ rustc +nightly --test -Z unpretty=hir test.rs
STEP1. RE-EXPORT STEP1. RE-EXPORT どうやって crate root から test_my_priv_func を⾒
るか︖ mod my_priv_func { fn my_priv_func() -> bool { true } #[test] fn test_my_priv_func() { assert!(my_priv_func()); } }
pub にして re-exportする mod my_priv_func { fn my_priv_func() -> bool
{ true } // 正確には少し違う pub fn test_my_priv_func() { assert!(my_priv_func()); } pub mod __test_reexports { pub use super::test_my_priv_func; } }
STEP2. HARNESS GENERATION STEP2. HARNESS GENERATION テスト⽤の main #[main] pub
fn main() { extern crate test; test::test_main_static(&[&path::to::test1, /*...*/]); }
STEP3. TEST OBJECT STEP3. TEST OBJECT GENERATION GENERATION test::TestDesc で
configuration を指定できる pub struct TestDesc { pub name: TestName, pub ignore: bool, pub should_panic: ShouldPanic, pub allow_fail: bool, }