1个不稳定版本

0.1.0 2019年4月30日

#1942过程宏

Apache-2.0

2KB

test-ignore-if

一个条件忽略测试的Rust过程宏

支持的条件

  • 构建时设置的构建环境变量

使用它

首先,您需要将此行添加到您的build.rs

test_ignore_if_utils::enable_ignore_if_env_set_for("CI")

这确保了当CI环境变量变化时,您的代码将被重新编译,并告知过程宏您已启用此功能

然后您可以为您的测试添加注解

use test_ignore_if::ignore_if;

#[ignore_if(env_set="CI")]
#[test]
fn it_works() {
    assert_eq!(2 + 2, 4);
} 

如果编译时设置了CI环境变量,则测试将被忽略

许可证

Copyright 2019 Thibaut Lorrain

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.

无运行时依赖