File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,13 @@ impl ReportData {
109109
110110impl Display for ReportData {
111111 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
112+ if self . 0 . is_empty ( ) {
113+ writeln ! (
114+ f,
115+ "\n No contract gas usage data to display. Make sure your test include transactions."
116+ ) ?;
117+ }
118+
112119 for ( name, contract_info) in & self . 0 {
113120 if !contract_info. functions . is_empty ( ) {
114121 let table = format_table_output ( contract_info, name) ;
Original file line number Diff line number Diff line change @@ -115,3 +115,30 @@ fn multiple_contracts_and_constructor() {
115115 " } ,
116116 ) ;
117117}
118+
119+ #[ test]
120+ fn no_transactions ( ) {
121+ let temp = setup_package ( "simple_package" ) ;
122+ let output = test_runner ( & temp)
123+ . arg ( "--gas-report" )
124+ . arg ( "test_fib" )
125+ . assert ( )
126+ . code ( 0 ) ;
127+
128+ assert_stdout_contains (
129+ output,
130+ indoc ! { r"
131+ [..]Compiling[..]
132+ [..]Finished[..]
133+
134+
135+ Collected 1 test(s) from simple_package package
136+ Running 1 test(s) from src/
137+ [PASS] simple_package::tests::test_fib (l1_gas: ~0, l1_data_gas: ~0, l2_gas: ~[..])
138+ No contract gas usage data to display. Make sure your test include transactions.
139+
140+ Running 0 test(s) from tests/
141+ Tests: 1 passed, 0 failed, 0 ignored, [..] filtered out
142+ " } ,
143+ ) ;
144+ }
You can’t perform that action at this time.
0 commit comments