Skip to content

Commit

Permalink
[fix] adjust tests and compile errors
Browse files Browse the repository at this point in the history
Signed-off-by: VAmuzing <[email protected]>
  • Loading branch information
VAmuzing committed Dec 27, 2023
1 parent 010d7c4 commit 0965600
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions telemetry/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ pub fn metrics(attr: TokenStream, item: TokenStream) -> TokenStream {
func.sig,
"Function must have at least one argument of type `WorldStateView`."
);
return emitter.finish_token_stream();
}

let Some(metric_specs): Option<MetricSpecs> = emitter.handle(syn2::parse2(attr)) else {
Expand Down
1 change: 1 addition & 0 deletions telemetry/derive/tests/ui_fail/not_execute.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use iroha_telemetry_derive::metrics;
use iroha_core::prelude::WorldStateView;

#[metrics(+"test_query", "another_test_query_without_timing")]
fn exequte(wsv: &WorldStateView) -> Result<(), ()> {
Expand Down
4 changes: 2 additions & 2 deletions telemetry/derive/tests/ui_fail/not_execute.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: Function should be an `impl execute`
--> tests/ui_fail/not_execute.rs:4:4
--> tests/ui_fail/not_execute.rs:5:4
|
4 | fn exequte(wsv: &WorldStateView) -> Result<(), ()> {
5 | fn exequte(wsv: &WorldStateView) -> Result<(), ()> {
| ^^^^^^^
7 changes: 5 additions & 2 deletions telemetry/derive/tests/ui_fail/not_return_result.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use iroha_telemetry_derive::metrics;
use iroha_core::prelude::WorldStateView;

type MyNotResult = Option<i32>;

#[metrics(+"test_query", "another_test_query_without_timing")]
fn execute(_wsv: &WorldStateView) -> iroha_core::RESULT {
Ok(())
fn execute(_wsv: &WorldStateView) -> MyNotResult {
None
}

fn main() {
Expand Down
8 changes: 4 additions & 4 deletions telemetry/derive/tests/ui_fail/not_return_result.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: Should return `Result`. Found RESULT
--> tests/ui_fail/not_return_result.rs:4:50
error: Should return `Result`. Found MyNotResult
--> tests/ui_fail/not_return_result.rs:7:38
|
4 | fn execute(_wsv: &WorldStateView) -> iroha_core::RESULT {
| ^^^^^^
7 | fn execute(_wsv: &WorldStateView) -> MyNotResult {
| ^^^^^^^^^^^
3 changes: 2 additions & 1 deletion telemetry/derive/tests/ui_fail/return_nothing.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use iroha_telemetry_derive::metrics;
use iroha_core::prelude::WorldStateView;

#[metrics(+"test_query", "another_test_query_without_timing")]
fn execute(wsv: &WorldStateView) {
Ok(())
Ok::<(), ()>(());
}

fn main() {
Expand Down
4 changes: 2 additions & 2 deletions telemetry/derive/tests/ui_fail/return_nothing.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: `Fn` must return `Result`. Returns nothing instead.
--> tests/ui_fail/return_nothing.rs:3:1
--> tests/ui_fail/return_nothing.rs:4:1
|
3 | #[metrics(+"test_query", "another_test_query_without_timing")]
4 | #[metrics(+"test_query", "another_test_query_without_timing")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro `metrics` (in Nightly builds, run with -Z macro-backtrace for more info)

0 comments on commit 0965600

Please sign in to comment.