Skip to content

Commit

Permalink
ui-tests: Check empty impl_runtime_apis
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandru Vasile <[email protected]>
  • Loading branch information
lexnv committed Mar 30, 2023
1 parent ca77baa commit cf78a71
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
35 changes: 35 additions & 0 deletions frame/support/test/tests/impl_runtime_apis_ui.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// This file is part of Substrate.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[rustversion::attr(not(stable), ignore)]
#[cfg(not(feature = "disable-ui-tests"))]
#[test]
fn impl_runtime_apis_ui() {
// Only run the ui tests when `RUN_UI_TESTS` is set.
if std::env::var("RUN_UI_TESTS").is_err() {
return
}

// As trybuild is using `cargo check`, we don't need the real WASM binaries.
std::env::set_var("SKIP_WASM_BUILD", "1");

// Deny all warnings since we emit warnings as part of a Pallet's UI.
std::env::set_var("RUSTFLAGS", "--deny warnings");

let t = trybuild::TestCases::new();
t.compile_fail("tests/impl_runtime_apis_ui/*.rs");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use frame_support::impl_runtime_apis;

// Do not use `construct_runtime!`.
struct Runtime;

// Empty `impl_runtime_apis!` cannot deduce the Runtime name
// and should not implement the `runtime_metadata()` method.
impl_runtime_apis! {}

// Expect the test to compile because this has the effect of
// not calling `construct_runtime!` nor `impl_runtime_apis!`
// for the Runtime.
fn main() {}

0 comments on commit cf78a71

Please sign in to comment.