Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ build:linux --copt=-Wno-deprecated-declarations
# you will typically need to spell out the compiler for local dev
# BAZEL_VC=<install directory>
# BAZEL_VC_FULL_VERSION=14.44.3520
# Some dependencies rely on bash so you will likely need msys2
# BAZEL_SH=C:\msys64\usr\bin\bash.exe
build:msvc --cxxopt="-std:c++20" --cxxopt="-utf-8" --host_cxxopt="-std:c++20"
build:msvc --define=protobuf_allow_msvc=true
build:msvc --test_tag_filters=-benchmark,-notap,-no_test_msvc
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/windows_bazel_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Windows Bazel Test

on:
workflow_call:
workflow_dispatch:

jobs:
test:
name: Run Bazel Tests
runs-on: windows-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Bazel and Bazelisk
uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true

- name: Run Tests
# msys2 'bash' on Windows will try to 'fix' the label prefix to
# work as a directory.
# //... won't work.
shell: bash
run: |
bazelisk test --config=msvc conformance:all
13 changes: 13 additions & 0 deletions .github/workflows/windows_bazel_test_post_merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Windows Bazel Test (Post-Merge)

on:
push:
branches:
- master

jobs:
trigger-test:
# This prevents the workflow from running automatically when someone
# pushes to their fork.
if: github.repository == 'google/cel-cpp'
uses: ./.github/workflows/windows_bazel_test.yml
1 change: 1 addition & 0 deletions conformance/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ cc_library(
deps = [
":service",
":utils",
"//internal:runfiles",
"//internal:testing_no_main",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log:absl_check",
Expand Down
2 changes: 1 addition & 1 deletion conformance/run.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _conformance_test_args(modern, optimize, recursive, select_opt, skip_check,
def _conformance_test(name, data, modern, optimize, recursive, select_opt, skip_check, skip_tests, tags, dashboard):
cc_test(
name = _conformance_test_name(name, optimize, recursive),
args = _conformance_test_args(modern, optimize, recursive, select_opt, skip_check, dashboard) + ["$(location " + test + ")" for test in data],
args = _conformance_test_args(modern, optimize, recursive, select_opt, skip_check, dashboard) + ["$(rlocationpath {})".format(test) for test in data],
env = select(
{
"@platforms//os:windows": {"CEL_SKIP_TESTS": ",".join(skip_tests + _TESTS_TO_SKIP_WINDOWS)},
Expand Down
7 changes: 4 additions & 3 deletions conformance/run.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "absl/types/span.h"
#include "conformance/service.h"
#include "conformance/utils.h"
#include "internal/runfiles.h"
#include "internal/testing.h"
#include "cel/expr/conformance/test/simple.pb.h"
#include "google/protobuf/io/zero_copy_stream_impl.h"
Expand All @@ -68,8 +69,6 @@ ABSL_FLAG(bool, select_optimization, false, "Enable select optimization.");

namespace {

using ::testing::IsEmpty;

using cel::expr::conformance::test::SimpleTest;
using cel::expr::conformance::test::SimpleTestFile;
using google::api::expr::conformance::v1alpha1::CheckRequest;
Expand All @@ -78,6 +77,7 @@ using google::api::expr::conformance::v1alpha1::EvalRequest;
using google::api::expr::conformance::v1alpha1::EvalResponse;
using google::api::expr::conformance::v1alpha1::ParseRequest;
using google::api::expr::conformance::v1alpha1::ParseResponse;
using ::testing::IsEmpty;

google::rpc::Code ToGrpcCode(absl::StatusCode code) {
return static_cast<google::rpc::Code>(code);
Expand Down Expand Up @@ -282,8 +282,9 @@ int main(int argc, char** argv) {
}
}
for (int argi = 1; argi < argc; argi++) {
std::string path = cel::internal::ResolveRunfilesPath(argv[argi]);
ABSL_CHECK_OK(RegisterTestsFromFile(service, tests_to_skip,
absl::string_view(argv[argi])));
absl::string_view(path)));
}
}
int exit_code = RUN_ALL_TESTS();
Expand Down
11 changes: 11 additions & 0 deletions internal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ cc_library(
],
)

cc_library(
name = "runfiles",
srcs = ["runfiles.cc"],
hdrs = ["runfiles.h"],
deps = [
"@com_google_absl//absl/log:absl_check",
"@com_google_absl//absl/strings",
"@rules_cc//cc/runfiles",
],
)

cc_library(
name = "status_builder",
hdrs = ["status_builder.h"],
Expand Down
40 changes: 40 additions & 0 deletions internal/runfiles.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2026 Google LLC
//
// 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
//
// https://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.

#include "internal/runfiles.h"

#include <string>

#include "rules_cc/cc/runfiles/runfiles.h"

#include "absl/log/absl_check.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"

namespace cel::internal {

std::string ResolveRunfilesPath(absl::string_view path) {
using ::rules_cc::cc::runfiles::Runfiles;
static Runfiles* runfiles = []() {
std::string error;
auto runfiles =
Runfiles::CreateForTest(BAZEL_CURRENT_REPOSITORY, &error);
ABSL_QCHECK(runfiles != nullptr)
<< absl::StrCat("failed to init runfiles", error);
return runfiles;
}();
return runfiles->Rlocation(std::string(path));
}

} // namespace cel::internal
30 changes: 30 additions & 0 deletions internal/runfiles.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2026 Google LLC
//
// 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
//
// https://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.

#ifndef THIRD_PARTY_CEL_CPP_INTERNAL_RUNFILES_H_
#define THIRD_PARTY_CEL_CPP_INTERNAL_RUNFILES_H_

#include <string>

#include "absl/strings/string_view.h"

namespace cel::internal {

// Resolves a path relative to the runfiles directory.
// Intended for resolving test cases from cel-spec and cel-policy.
std::string ResolveRunfilesPath(absl::string_view path);

} // namespace cel::internal

#endif // THIRD_PARTY_CEL_CPP_INTERNAL_RUNFILES_H_
Loading