Merge changes from topic "rust_aconfig-test-mode" into main

* changes:
  Add rust_test with rust_aconfig_library in test mode
  Fix rust aconfig test
This commit is contained in:
Vinh Tran 2023-08-17 14:48:37 +00:00 committed by Gerrit Code Review
commit 73b4f2d4e2
4 changed files with 50 additions and 9 deletions

View file

@ -160,11 +160,28 @@ rust_aconfig_library {
}
rust_test {
name: "aconfig.test.rust",
name: "aconfig.prod_mode.test.rust",
srcs: [
"tests/aconfig_test.rs"
"tests/aconfig_prod_mode_test.rs"
],
rustlibs: [
"libaconfig_test_rust_library",
],
}
rust_aconfig_library {
name: "libaconfig_test_rust_library_with_test_mode",
crate_name: "aconfig_test_rust_library",
aconfig_declarations: "aconfig.test.flags",
test: true,
}
rust_test {
name: "aconfig.test_mode.test.rust",
srcs: [
"tests/aconfig_test_mode_test.rs"
],
rustlibs: [
"libaconfig_test_rust_library_with_test_mode",
],
}

View file

@ -0,0 +1,8 @@
#[test]
fn test_flags() {
assert!(!aconfig_test_rust_library::disabled_ro());
assert!(!aconfig_test_rust_library::disabled_rw());
// TODO: Fix template to not default both disabled and enabled to false
assert!(!aconfig_test_rust_library::enabled_ro());
assert!(!aconfig_test_rust_library::enabled_rw());
}

View file

@ -1,7 +0,0 @@
#[test]
fn test_flags() {
assert!(!aconfig_test_rust_library::disabled_ro());
assert!(!aconfig_test_rust_library::disabled_rw());
assert!(aconfig_test_rust_library::enabled_ro());
assert!(aconfig_test_rust_library::enabled_rw());
}

View file

@ -0,0 +1,23 @@
#[test]
fn test_flags() {
assert!(!aconfig_test_rust_library::disabled_ro());
assert!(!aconfig_test_rust_library::disabled_rw());
// TODO: Fix template to not default both disabled and enabled to false
assert!(!aconfig_test_rust_library::enabled_ro());
assert!(!aconfig_test_rust_library::enabled_rw());
aconfig_test_rust_library::set_disabled_ro(true);
assert!(aconfig_test_rust_library::disabled_ro());
aconfig_test_rust_library::set_disabled_rw(true);
assert!(aconfig_test_rust_library::disabled_rw());
aconfig_test_rust_library::set_enabled_ro(true);
assert!(aconfig_test_rust_library::enabled_ro());
aconfig_test_rust_library::set_enabled_rw(true);
assert!(aconfig_test_rust_library::enabled_rw());
aconfig_test_rust_library::reset_flags();
assert!(!aconfig_test_rust_library::disabled_ro());
assert!(!aconfig_test_rust_library::disabled_rw());
assert!(!aconfig_test_rust_library::enabled_ro());
assert!(!aconfig_test_rust_library::enabled_rw());
}