Skip to content

Commit

Permalink
feat: Enable gmock and upgrade gtest to 1.13 (#4480)
Browse files Browse the repository at this point in the history
We enable gmock from gtest. However, a compilation issue required to use
version >= 1.13.
The latest version 1.14 leads to a compilation issue with the current
gcc used in the CI job. It is apparently related to a gcc compiler issue
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105329)

---------

Co-authored-by: ludamad <adam.domurad@gmail.com>
  • Loading branch information
2 people authored and TomAFrench committed Feb 7, 2024
1 parent b65428e commit dc6e611
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/protocol-circuits-gate-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ inputs.tag || env.GITHUB_REF }}

- name: Install bleeding edge cmake
run: |
Expand Down
11 changes: 4 additions & 7 deletions barretenberg/cpp/cmake/gtest.cmake
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
include(GoogleTest)
include(FetchContent)

set(BUILD_GMOCK ON CACHE INTERNAL BOOL "Build with gMock enabled")
set(INSTALL_GTEST OFF CACHE BOOL "gTest installation disabled")

FetchContent_Declare(
GTest
GIT_REPOSITORY https://github.com/google/googletest.git
# Version 1.12.1 is not compatible with WASI-SDK 12
GIT_TAG release-1.10.0
GIT_TAG v1.13.0 #v1.14.0 does not compile with gcc (compiler bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105329)
FIND_PACKAGE_ARGS
)

set(BUILD_GMOCK OFF CACHE BOOL "Build with gMock disabled")
set(INSTALL_GTEST OFF CACHE BOOL "gTest installation disabled")

FetchContent_MakeAvailable(GTest)

if (NOT GTest_FOUND)
Expand Down Expand Up @@ -42,8 +41,6 @@ if (NOT GTest_FOUND)
gtest_disable_pthreads gtest_force_shared_crt gtest_hide_internal_symbols
)

add_library(GTest::gtest ALIAS gtest)
add_library(GTest::gtest_main ALIAS gtest_main)
endif()

enable_testing()
3 changes: 3 additions & 0 deletions barretenberg/cpp/cmake/module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ function(barretenberg_module MODULE_NAME)
${MODULE_NAME}_test_objects
PRIVATE
GTest::gtest
GTest::gtest_main
GTest::gmock_main
${TBB_IMPORTED_TARGETS}
)

Expand Down Expand Up @@ -118,6 +120,7 @@ function(barretenberg_module MODULE_NAME)
${ARGN}
GTest::gtest
GTest::gtest_main
GTest::gmock_main
${TBB_IMPORTED_TARGETS}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "barretenberg/vm/avm_trace/AvmMini_opcode.hpp"
#include "barretenberg/vm/tests/helpers.test.hpp"
#include <cstdint>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <string>
#include <utility>
Expand Down Expand Up @@ -64,7 +65,7 @@ TEST_F(AvmMiniExecutionTests, basicAddReturn)
auto instructions = Deserialization::parse(bytecode);

// 2 instructions
EXPECT_EQ(instructions.size(), 2);
EXPECT_THAT(instructions, testing::SizeIs(2));

// ADD
EXPECT_EQ(instructions.at(0).op_code, OpCode::ADD);
Expand Down

0 comments on commit dc6e611

Please sign in to comment.