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
10 changes: 10 additions & 0 deletions bazel/envoy_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,16 @@ def envoy_cc_test_library(name,
linkstatic = 1,
)

# Envoy Python test binaries should be specified with this function.
def envoy_py_test_binary(name,
external_deps = [],
**kargs):
# TODO(htuch): Add support for external_deps, e.g. jinja2 for config_test.
native.py_binary(
name = name,
**kargs
)

# Envoy C++ mock targets should be specified with this function.
def envoy_cc_mock(name, **kargs):
envoy_cc_test_library(name = name, **kargs)
Expand Down
9 changes: 1 addition & 8 deletions test/common/json/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@ package(default_visibility = ["//visibility:public"])

load("//bazel:envoy_build_system.bzl", "envoy_cc_test")

filegroup(
name = "config_schema_test_generator",
srcs = glob([
"config_schemas_test_data/*.py",
]),
)

envoy_cc_test(
name = "config_schemas_test",
srcs = ["config_schemas_test.cc"],
data = [
"//test/common/json:config_schema_test_generator",
"//test/common/json/config_schemas_test_data:generate_test_data",
],
deps = [
"//source/common/json:config_schemas_lib",
Expand Down
6 changes: 4 additions & 2 deletions test/common/json/config_schemas_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ namespace Json {

std::vector<std::string> generateTestInputs() {
TestEnvironment::exec({TestEnvironment::runfilesPath(
"test/common/json/config_schemas_test_data/generate_test_data.py")});
"test/common/json/config_schemas_test_data/generate_test_data")});

std::string test_path = TestEnvironment::temporaryDirectory() + "/config_schemas_test";
return TestUtility::listFiles(test_path, false);
auto file_list = TestUtility::listFiles(test_path, false);
EXPECT_EQ(17, file_list.size());
return file_list;
}

class ConfigSchemasTest : public ::testing::TestWithParam<std::string> {};
Expand Down
11 changes: 11 additions & 0 deletions test/common/json/config_schemas_test_data/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package(default_visibility = ["//visibility:public"])

load("//bazel:envoy_build_system.bzl", "envoy_py_test_binary")

envoy_py_test_binary(
name = "generate_test_data",
srcs = [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not positive, but I'm guessing that unless you export the other python files in the directory, the actual schema tests in the other files won't run. We might want to put some expected number of loaded test files in the test main loop to catch this (like I recently did for the example config tests).

"generate_test_data.py",
"util.py",
] + glob(["test_*.py"]),
)
1 change: 1 addition & 0 deletions test/common/runtime/filesystem_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ set -e

cd ${TEST_SRCDIR}/${TEST_WORKSPACE}
cp -rfL --parents test/common/runtime/test_data ${TEST_TMPDIR}
chmod -R u+rwX ${TEST_TMPDIR}/test/common/runtime/test_data
ln -sf ${TEST_TMPDIR}/test/common/runtime/test_data/root ${TEST_TMPDIR}/test/common/runtime/test_data/current
ln -sf ${TEST_TMPDIR}/test/common/runtime/test_data/root/envoy/subdir ${TEST_TMPDIR}/test/common/runtime/test_data/root/envoy/badlink