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
1 change: 1 addition & 0 deletions test/config_test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ envoy_cc_test(
],
deps = [
":config_test_lib",
"//source/common/filesystem:filesystem_lib",
"//test/test_common:environment_lib",
"//test/test_common:utility_lib",
],
Expand Down
19 changes: 13 additions & 6 deletions test/config_test/example_configs_test.cc
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
#include "common/filesystem/filesystem_impl.h"

#include "test/config_test/config_test.h"
#include "test/test_common/environment.h"
#include "test/test_common/utility.h"

#include "gtest/gtest.h"

namespace Envoy {

TEST(ExampleConfigsTest, All) {
TestEnvironment::exec(
{TestEnvironment::runfilesPath("test/config_test/example_configs_test_setup.sh")});

#ifdef WIN32
Filesystem::InstanceImplWin32 file_system;
#else
Filesystem::InstanceImplPosix file_system;
#endif

const auto config_file_count = std::stoi(
file_system.fileReadToEnd(TestEnvironment::temporaryDirectory() + "/config-file-count.txt"));

// Change working directory, otherwise we won't be able to read files using relative paths.
#ifdef PATH_MAX
char cwd[PATH_MAX];
Expand All @@ -19,12 +31,7 @@ TEST(ExampleConfigsTest, All) {
RELEASE_ASSERT(::getcwd(cwd, sizeof(cwd)) != nullptr, "");
RELEASE_ASSERT(::chdir(directory.c_str()) == 0, "");

#if defined(__APPLE__) || defined(WIN32)
// freebind/freebind.yaml is not supported on macOS or Windows and is disabled via Bazel.
EXPECT_EQ(37UL, ConfigTest::run(directory));
#else
EXPECT_EQ(38UL, ConfigTest::run(directory));
#endif
EXPECT_EQ(config_file_count, ConfigTest::run(directory));

ConfigTest::testMerge();

Expand Down
3 changes: 3 additions & 0 deletions test/config_test/example_configs_test_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ set -e
DIR="$TEST_TMPDIR"/test/config_test
mkdir -p "$DIR"
tar -xvf "$TEST_SRCDIR"/envoy/configs/example_configs.tar -C "$DIR"

# find uses full path to prevent using Windows find on Windows.
/usr/bin/find "$DIR" -type f | grep -c .yaml > "$TEST_TMPDIR"/config-file-count.txt
Copy link
Member

Choose a reason for hiding this comment

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

Can we use /usr/bin/env's help? Not sure about Windows 😅.

Copy link
Member Author

Choose a reason for hiding this comment

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

not sure how that would work on windows - just waiting to see if the full path fixes the problem...

Copy link
Member Author

@phlax phlax Sep 22, 2020

Choose a reason for hiding this comment

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

full path fixed the find issue

a quick search of "windows /usr/bin/env find" doesnt seem to suggest that would work (or otherwise really) - i think probably just using the full path should be safe/r

Copy link
Member

Choose a reason for hiding this comment

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

Yeah using #!/usr/bin/env bash, /c/Windows/System32 shows up on the PATH first still, to get around that we would have to do some PATH ordering magic somewhere