Skip to content

Commit

Permalink
bazel, .github/workflows: Add //:minimal_test that should pass even i…
Browse files Browse the repository at this point in the history
…f shared libs are missing on the machine / in RBE containers.
  • Loading branch information
ivucica committed Aug 12, 2024
1 parent 50c829f commit 441a0b2
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 2 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/ci-bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ jobs:
bazel_test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- name: minimal test
bazel_target: //:minimal_test
- name: util test
bazel_target: //:util_test

needs: [bazel_build]
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, which is the CWD for
Expand Down Expand Up @@ -87,7 +96,7 @@ jobs:
- name: install deps without prebuilt SDL (bazel)
run: sudo apt-get update && sudo apt-get install autoconf automake libgl1-mesa-dev libglu1-mesa-dev libx11-dev libxext-dev libxrandr-dev libxrender-dev libasound-dev libalsaplayer-dev
- name: bazel test
run: bazel test //:util_test
run: bazel test ${{ matrix.bazel_target }}

bazel_build_buildbuddy:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -126,6 +135,15 @@ jobs:
bazel_test_buildbuddy:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- name: minimal test
bazel_target: //:minimal_test
- name: util test
bazel_target: //:util_test

needs: [bazel_build_buildbuddy]
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, which is the CWD for
Expand Down Expand Up @@ -157,7 +175,7 @@ jobs:
# More useful with e.g. npm.

- name: rbe bazel test
run: bazel test --config=remote --build_metadata=ROLE=CI ${BUILDBUDDY_ORG_API_KEY:+--remote_header=x-buildbuddy-api-key=${BUILDBUDDY_ORG_API_KEY}} //:util_test
run: bazel test --config=remote --build_metadata=ROLE=CI ${BUILDBUDDY_ORG_API_KEY:+--remote_header=x-buildbuddy-api-key=${BUILDBUDDY_ORG_API_KEY}} ${{ matrix.bazel_target }}
# Temporarily allow errors. This is known to fail at this time due to insufficient
# number of binary packages installed by the rules_libsdl12.
continue-on-error: true
Expand Down
10 changes: 10 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,16 @@ cc_test(
linkopts = ["-ldl"],
)

cc_test(
# This test intentionally links nothing except gtest.
name = "minimal_test",
size = "small",
srcs = ["minimal_test.cpp"],
deps = [
"@com_google_googletest//:gtest_main",
],
)

cc_library(
name = "macutil",
srcs = select({
Expand Down
37 changes: 37 additions & 0 deletions minimal_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//////////////////////////////////////////////////////////////////////
// Yet Another Tibia Client
//////////////////////////////////////////////////////////////////////
// Minimal test to verify the test system itself works.
//////////////////////////////////////////////////////////////////////
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//////////////////////////////////////////////////////////////////////

#include <string>
#include <gtest/gtest.h>

// Demonstrate some basic assertions.
TEST(StrReplaceTest, BasicAssertions) {
auto haystack = std::string("hello world");
auto needle = std::string("hello");
auto replace = std::string("hi");

auto got =
haystack.replace(haystack.find(needle), needle.size(), replace);
auto want = "hi world";

EXPECT_STREQ(got.c_str(), want);
// Expect equality.
//EXPECT_EQ(7 * 6, 42);
}

0 comments on commit 441a0b2

Please sign in to comment.