Adopt Googletest where possible
PiperOrigin-RevId: 665369043
Change-Id: I7b97a3388ba83fcccca13f239af3278fb0af5d68
diff --git a/bazel/llvm.bzl b/bazel/llvm.bzl
index fa45957..58a5f32 100644
--- a/bazel/llvm.bzl
+++ b/bazel/llvm.bzl
@@ -53,7 +53,7 @@
executable = False,
)
-LLVM_COMMIT_SHA = "1115dee248e68a155001ac3712a189299d104863"
+LLVM_COMMIT_SHA = "60bffe221a1d615ffc7c6b632287d0fbd27ef863"
def llvm_loader_repository_dependencies():
# This *declares* the dependency, but it won't actually be *downloaded* unless it's used.
diff --git a/common/item_exists_test.rs b/common/item_exists_test.rs
index b2cc114..3b1f66f 100644
--- a/common/item_exists_test.rs
+++ b/common/item_exists_test.rs
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+use googletest::prelude::*;
+
// shadow core and std to try to break the proc macro :)
mod std {}
mod core {}
@@ -10,13 +12,13 @@
#[allow(unused_imports)]
use super::*;
- #[test]
+ #[gtest]
fn type_doesnt_exist() {
mod m {}
assert!(!item_exists::type_exists!(m::DoesNotExist));
}
- #[test]
+ #[gtest]
fn struct_does_exist() {
mod m {
pub struct S {}
@@ -24,7 +26,7 @@
assert!(item_exists::type_exists!(m::S));
}
- #[test]
+ #[gtest]
fn unit_struct_does_exist() {
mod m {
pub struct S;
@@ -32,7 +34,7 @@
assert!(item_exists::type_exists!(m::S));
}
- #[test]
+ #[gtest]
fn tuple_struct_does_exist() {
mod m {
pub struct S();
@@ -40,7 +42,7 @@
assert!(item_exists::type_exists!(m::S));
}
- #[test]
+ #[gtest]
fn enum_does_exist() {
mod m {
pub enum E {}
@@ -48,7 +50,7 @@
assert!(item_exists::type_exists!(m::E));
}
- #[test]
+ #[gtest]
fn union_does_exist() {
mod m {
pub union U {
@@ -60,7 +62,7 @@
/// When we use the same name in a type context, we find no such type
/// exists.
- #[test]
+ #[gtest]
fn function_doesnt_exist() {
mod m {
#[allow(unused)]
@@ -69,7 +71,7 @@
assert!(!item_exists::type_exists!(m::foo));
}
- #[test]
+ #[gtest]
fn constant_doesnt_exist() {
mod m {
#[allow(unused)]
@@ -78,7 +80,7 @@
assert!(!item_exists::type_exists!(m::X));
}
- #[test]
+ #[gtest]
fn static_doesnt_exist() {
mod m {
#[allow(unused)]
@@ -87,7 +89,7 @@
assert!(!item_exists::type_exists!(m::X));
}
- #[test]
+ #[gtest]
fn mod_doesnt_exist() {
mod m {
mod m2 {}
@@ -95,7 +97,7 @@
assert!(!item_exists::type_exists!(m::m2));
}
- #[test]
+ #[gtest]
fn nested_module() {
mod m {
pub mod m2 {
@@ -107,17 +109,17 @@
assert!(!item_exists::type_exists!(m::m2::DoesNotExist));
}
- #[test]
+ #[gtest]
fn std_type() {
assert!(item_exists::type_exists!(::std::num::NonZeroU8));
}
- #[test]
+ #[gtest]
fn function_type() {
assert!(item_exists::type_exists!(::std::num::NonZeroU8));
}
- #[test]
+ #[gtest]
fn alias() {
mod m {
pub type X = ::std::num::NonZeroU8;
@@ -125,7 +127,7 @@
assert!(item_exists::type_exists!(m::X));
}
- #[test]
+ #[gtest]
fn use_alias() {
mod m {
pub use ::std::num::NonZeroU8 as X;
@@ -135,7 +137,7 @@
/// Invoke the proc-macro twice in the same scope. This can expose some
/// implementation errors.
- #[test]
+ #[gtest]
fn type_exists_twice() {
mod m {
pub struct A;
@@ -149,13 +151,13 @@
#[allow(unused_imports)]
use super::*;
- #[test]
+ #[gtest]
fn value_doesnt_exist() {
mod m {}
assert!(!item_exists::value_exists!(m::does_not_exist));
}
- #[test]
+ #[gtest]
fn struct_doesnt_exist() {
mod m {
#[allow(dead_code)]
@@ -166,7 +168,7 @@
/// In type_exists!, we find the type. In value_exists!, we find the
/// _constant_.
- #[test]
+ #[gtest]
fn unit_struct_does_exist() {
mod m {
pub struct S;
@@ -177,7 +179,7 @@
/// This one may be surprising, but it's ultimately similar to unit structs.
/// In type_exists!, we find the type. In value_exists!, we find the
/// _constructor_, a function.
- #[test]
+ #[gtest]
fn tuple_struct_does_exist() {
mod m {
pub struct S();
@@ -185,7 +187,7 @@
assert!(item_exists::value_exists!(m::S));
}
- #[test]
+ #[gtest]
fn enum_doesnt_exist() {
mod m {
#[allow(dead_code)]
@@ -194,7 +196,7 @@
assert!(!item_exists::value_exists!(m::E));
}
- #[test]
+ #[gtest]
fn union_doesnt_exist() {
mod m {
#[allow(dead_code)]
@@ -205,7 +207,7 @@
assert!(!item_exists::value_exists!(m::U));
}
- #[test]
+ #[gtest]
fn function_does_exist() {
mod m {
pub fn foo() {}
@@ -213,7 +215,7 @@
assert!(item_exists::value_exists!(m::foo));
}
- #[test]
+ #[gtest]
fn constant_does_exist() {
mod m {
pub const X: () = ();
@@ -221,7 +223,7 @@
assert!(item_exists::value_exists!(m::X));
}
- #[test]
+ #[gtest]
fn static_does_exist() {
mod m {
pub static X: () = ();
@@ -229,7 +231,7 @@
assert!(item_exists::value_exists!(m::X));
}
- #[test]
+ #[gtest]
fn mod_doesnt_exist() {
mod m {
mod m2 {}
@@ -237,7 +239,7 @@
assert!(!item_exists::value_exists!(m::m2));
}
- #[test]
+ #[gtest]
fn nested_module() {
mod m {
pub mod m2 {
@@ -249,12 +251,12 @@
assert!(!item_exists::value_exists!(m::m2::DoesNotExist));
}
- #[test]
+ #[gtest]
fn std_value() {
assert!(item_exists::value_exists!(::std::f32::consts::E));
}
- #[test]
+ #[gtest]
fn alias_doesnt_exist() {
mod m {
#[allow(dead_code)]
@@ -263,7 +265,7 @@
assert!(!item_exists::value_exists!(m::X));
}
- #[test]
+ #[gtest]
fn use_alias_doesnt_exist() {
mod m {
#[allow(unused_imports)]
@@ -272,7 +274,7 @@
assert!(!item_exists::value_exists!(m::X));
}
- #[test]
+ #[gtest]
fn use_const_does_exist() {
mod m {
pub use ::std::f32::consts::E as X;
diff --git a/support/cc_std/test/string_view/test.rs b/support/cc_std/test/string_view/test.rs
index be7e78c..ed58c97 100644
--- a/support/cc_std/test/string_view/test.rs
+++ b/support/cc_std/test/string_view/test.rs
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
use cc_std::*;
+use googletest::prelude::*;
use string_view_apis::crubit_string_view::GetHelloWorld;
/// Converts a string_view to a &'static str.
@@ -15,7 +16,7 @@
}
/// An empty slice round trips, but the pointer value may change.
-#[test]
+#[gtest]
fn test_round_trip_empty_slice() {
// we need to create an empty slice somewhere specific in memory in order to
// test the pointer-value-discarding behavior, so let's create an array on
@@ -28,14 +29,14 @@
assert_eq!(unsafe { &*raw_round_tripped }, original);
}
-#[test]
+#[gtest]
fn test_round_trip_str() {
let original: &'static str = "this is a string";
let sv: std::string_view = original.into();
assert_eq!(unsafe { to_str(sv) }, original);
}
-#[test]
+#[gtest]
fn test_round_trip_cstr() {
let original: &'static str = "hello, world\0";
let cstr = core::ffi::CStr::from_bytes_with_nul(original.as_bytes()).unwrap();
@@ -44,7 +45,7 @@
assert_eq!(unsafe { to_str(sv) }, original);
}
-#[test]
+#[gtest]
fn test_ffi() {
assert_eq!(unsafe { to_str(GetHelloWorld()) }, "Hello, world!");
}
diff --git a/support/ctor_macro_test.rs b/support/ctor_macro_test.rs
index f58e80c..b7ccceb 100644
--- a/support/ctor_macro_test.rs
+++ b/support/ctor_macro_test.rs
@@ -11,12 +11,14 @@
// Allow unused imports so that we can produce pathological aliases.
#![allow(unused_imports)]
+use googletest::prelude::*;
+
// pathological shadowed names: shadow important modules that the macros use.
mod std {}
mod ctor {}
/// Expand emplace!{let ...} to test for hygiene.
-#[test]
+#[gtest]
fn test_emplace_stmt_hygiene() {
::ctor::emplace! {
let _x1 = 0;
@@ -27,13 +29,13 @@
}
/// Expand emplace!(expr) to test for hygiene.
-#[test]
+#[gtest]
fn test_emplace_expr_hygiene() {
let _ = ::ctor::emplace!(4);
}
/// Expand ctor!{Struct{...}} to test for hygiene.
-#[test]
+#[gtest]
fn test_ctor_struct_hygiene() {
struct Struct {
x: i32,
@@ -45,7 +47,7 @@
}
/// Expand ctor!{TupleStruct(...)} to test for hygiene.
-#[test]
+#[gtest]
fn test_ctor_tuple_struct_hygiene() {
struct TupleStruct(i32);
unsafe impl ::ctor::RecursivelyPinned for TupleStruct {
diff --git a/support/ctor_proc_macros_test.rs b/support/ctor_proc_macros_test.rs
index 235dbd1..5aecff8 100644
--- a/support/ctor_proc_macros_test.rs
+++ b/support/ctor_proc_macros_test.rs
@@ -15,12 +15,14 @@
// more_qualified_paths is used to make project_pin_type!() simpler to use.
#![feature(negative_impls)]
+use googletest::prelude::*;
+
// pathological shadowed names: shadow important modules that the macros use.
mod std {}
mod ctor {}
mod pin_project {}
-#[test]
+#[gtest]
fn test_derive_default_unit_struct() {
#[derive(::ctor::CtorFrom_Default)]
struct Struct;
@@ -32,7 +34,7 @@
::ctor::emplace! {let _p = <Struct as ::ctor::CtorNew<()>>::ctor_new(()); }
}
-#[test]
+#[gtest]
fn test_derive_default_struct() {
#[derive(::ctor::CtorFrom_Default)]
struct Struct {
@@ -49,7 +51,7 @@
assert_eq!(p.y, 0.0);
}
-#[test]
+#[gtest]
fn test_derive_default_tuple_struct() {
#[derive(::ctor::CtorFrom_Default)]
struct Struct(i32, f32);
@@ -63,7 +65,7 @@
assert_eq!(p.1, 0.0);
}
-#[test]
+#[gtest]
fn test_recursively_pinned_unit_struct() {
#[::ctor::recursively_pinned]
struct S;
@@ -71,7 +73,7 @@
assert_eq!(::std::mem::size_of::<::ctor::project_pin_type!(S)>(), 0);
}
-#[test]
+#[gtest]
fn test_recursively_pinned_fieldless_struct() {
#[::ctor::recursively_pinned]
struct S {}
@@ -83,7 +85,7 @@
assert_eq!(::std::mem::size_of::<::ctor::project_pin_type!(S)>(), 0);
}
-#[test]
+#[gtest]
fn test_recursively_pinned_fieldless_tuple_struct() {
#[::ctor::recursively_pinned]
struct S();
@@ -91,7 +93,7 @@
assert_eq!(::std::mem::size_of::<::ctor::project_pin_type!(S)>(), 0);
}
-#[test]
+#[gtest]
fn test_recursively_pinned_fieldless_enum() {
#[::ctor::recursively_pinned]
enum E {
@@ -101,7 +103,7 @@
assert_eq!(::std::mem::size_of::<::ctor::project_pin_type!(E)>(), 0);
}
-#[test]
+#[gtest]
fn test_recursively_pinned_in_module() {
mod submodule {
#[::ctor::recursively_pinned]
@@ -110,7 +112,7 @@
let _: ::ctor::project_pin_type!(submodule::S) = Box::pin(submodule::S).as_mut().project_pin();
}
-#[test]
+#[gtest]
fn test_recursively_pinned_struct() {
#[::ctor::recursively_pinned]
struct S {
@@ -125,7 +127,7 @@
.x;
}
-#[test]
+#[gtest]
fn test_recursively_pinned_tuple_struct() {
#[::ctor::recursively_pinned]
struct S(i32);
@@ -135,7 +137,7 @@
// TODO(b/331688163): remove this workaround.
type Identity<T> = T;
-#[test]
+#[gtest]
fn test_recursively_pinned_enum_struct() {
#[::ctor::recursively_pinned]
enum E {
@@ -148,7 +150,7 @@
}
}
-#[test]
+#[gtest]
fn test_recursively_pinned_enum_tuple() {
#[::ctor::recursively_pinned]
enum E {
@@ -161,7 +163,7 @@
}
}
-#[test]
+#[gtest]
fn test_recursively_pinned_generic() {
#[::ctor::recursively_pinned]
struct S<'proj, 'proj_2: 'proj, 'proj_4, T>
@@ -183,7 +185,7 @@
.x;
}
-#[test]
+#[gtest]
fn test_recursively_pinned_struct_derive_default() {
#[::ctor::recursively_pinned]
#[derive(::ctor::CtorFrom_Default)]
@@ -201,7 +203,7 @@
/// The same as the previous test, but with the attribute order swapped.
/// This only compiles with macro_attributes_in_derive_output.
-#[test]
+#[gtest]
fn test_derive_default_recursively_pinned_struct() {
#[derive(::ctor::CtorFrom_Default)]
#[::ctor::recursively_pinned]
@@ -215,7 +217,7 @@
assert_eq!(p.y, 0.0);
}
-#[test]
+#[gtest]
fn test_recursively_pinned_actually_pinned() {
#[::ctor::recursively_pinned]
struct Struct {
@@ -248,7 +250,7 @@
// * implemented PinnedDrop, but forgot to pass in PinnedDrop to
// `::ctor::recursively_pinned`.
-#[test]
+#[gtest]
fn test_pinned_drop() {
use ::std::cell::Cell;
use ::std::rc::Rc;
diff --git a/support/forward_declare_macros_test.rs b/support/forward_declare_macros_test.rs
index 7ad8671..d21b5b4 100644
--- a/support/forward_declare_macros_test.rs
+++ b/support/forward_declare_macros_test.rs
@@ -2,6 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+use googletest::prelude::*;
+
// pathological shadowed names: shadow important modules that the macros use.
mod std {}
mod forward_declare {}
@@ -31,7 +33,7 @@
}
}
-#[test]
+#[gtest]
fn test_conversions() {
use ::forward_declare::CcCast as _; // test becomes too verbose otherwise.
struct MyType;
@@ -140,7 +142,7 @@
/// You should be able to call unsafe_define!() twice (on different types) in
/// the same scope.
-#[test]
+#[gtest]
fn test_hygiene() {
struct MyType1;
type MyTypeSymbol1 = ::forward_declare::symbol!("X1");
@@ -157,7 +159,7 @@
///
/// (The reverse direction, fundamentally, is a lot less likely to work in
/// idiomatic code.)
-#[test]
+#[gtest]
fn test_formerly_incomplete() {
use ::forward_declare::CcCast as _; // test becomes too verbose otherwise.
struct MyType;
@@ -209,7 +211,7 @@
/// We can then add an additional trait bound on all methods, `where T :
/// Complete`. This turns out to be easier, for silly typing reasons, than
/// defining a whole new vector type for incomplete T.
-#[test]
+#[gtest]
fn test_vector_alike() {
use ::forward_declare::{
forward_declare, internal::CcType, symbol, unsafe_define, CcCast, Complete,