[build][cmake] Fix windows tests and re-enable CI tests (#5674)

This commit is contained in:
Ryan Blue
2023-09-22 18:39:35 -04:00
committed by GitHub
parent 2b58bbde0b
commit e8d4a20331
9 changed files with 78 additions and 41 deletions

View File

@@ -49,7 +49,7 @@ jobs:
- name: build
working-directory: build
run: cmake --build .
run: cmake --build . --parallel $(nproc)
- name: test
working-directory: build
@@ -75,8 +75,23 @@ jobs:
run: python -m pip install jinja2
- name: configure
run: cmake -S . -B build -G "Ninja Multi-Config" -DCMAKE_BUILD_TYPE=Release -DWITH_JAVA=OFF -DWITH_EXAMPLES=ON -DWITH_TESTS=OFF -DUSE_SYSTEM_FMTLIB=ON -DUSE_SYSTEM_LIBUV=ON -DUSE_SYSTEM_EIGEN=ON -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_INSTALL_OPTIONS=--clean-after-build -DVCPKG_TARGET_TRIPLET=x64-windows-release -DVCPKG_HOST_TRIPLET=x64-windows-release
run: cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DWITH_JAVA=OFF -DWITH_EXAMPLES=ON -DUSE_SYSTEM_FMTLIB=ON -DUSE_SYSTEM_LIBUV=ON -DUSE_SYSTEM_EIGEN=ON -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_INSTALL_OPTIONS=--clean-after-build -DVCPKG_TARGET_TRIPLET=x64-windows-release -DVCPKG_HOST_TRIPLET=x64-windows-release
# Build wpiutil at full speed, wpimath depends on wpiutil
- name: build wpiutil
working-directory: build
run: cmake --build . --parallel $(nproc) --target wpiutil/all
# Build wpimath slow to prevent OOM
- name: build wpimath
working-directory: build
run: cmake --build . --parallel 1 --target wpimath/all
# Build everything else fast
- name: build
working-directory: build
run: cmake --build . --parallel 1 --config Release
run: cmake --build . --parallel $(nproc)
- name: test
working-directory: build
run: ctest --output-on-failure

View File

@@ -65,6 +65,7 @@ endif()
add_executable(glass ${glass_src} ${glass_resources_src} ${glass_rc} ${APP_ICON_MACOSX})
wpilib_link_macos_gui(glass)
wpilib_target_warnings(glass)
target_link_libraries(glass libglassnt libglass)
if (WIN32)

View File

@@ -19,3 +19,5 @@ endif()
target_compile_features(gtest PUBLIC cxx_std_20)
target_compile_features(gtest_main PUBLIC cxx_std_20)
target_compile_features(gmock PUBLIC cxx_std_20)
target_compile_features(gmock_main PUBLIC cxx_std_20)

View File

@@ -86,6 +86,7 @@ if (WITH_JAVA)
endif()
add_executable(ntcoredev src/dev/native/cpp/main.cpp)
wpilib_target_warnings(ntcoredev)
target_link_libraries(ntcoredev ntcore)
if (WITH_TESTS)

View File

@@ -254,9 +254,11 @@ TEST_F(LocalStorageTest, PubUnpubPub) {
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"boolean"}, wpi::json::object(),
IsDefaultPubSubOptions()));
EXPECT_CALL(logger, Call(NT_LOG_INFO, _, _,
"local subscribe to 'foo' disabled due to type "
"mismatch (wanted 'int', published as 'boolean')"));
EXPECT_CALL(logger,
Call(NT_LOG_INFO, _, _,
std::string_view{
"local subscribe to 'foo' disabled due to type "
"mismatch (wanted 'int', published as 'boolean')"}));
auto pub = storage.Publish(fooTopic, NT_BOOLEAN, "boolean", {}, {});
auto val = Value::MakeBoolean(true, 5);
@@ -298,9 +300,11 @@ TEST_F(LocalStorageTest, LocalPubConflict) {
IsDefaultPubSubOptions()));
auto pub1 = storage.Publish(fooTopic, NT_BOOLEAN, "boolean", {}, {});
EXPECT_CALL(logger, Call(NT_LOG_INFO, _, _,
"local publish to 'foo' disabled due to type "
"mismatch (wanted 'int', currently 'boolean')"));
EXPECT_CALL(
logger,
Call(NT_LOG_INFO, _, _,
std::string_view{"local publish to 'foo' disabled due to type "
"mismatch (wanted 'int', currently 'boolean')"}));
auto pub2 = storage.Publish(fooTopic, NT_INTEGER, "int", {}, {});
EXPECT_EQ(storage.GetTopicType(fooTopic), NT_BOOLEAN);
@@ -337,9 +341,11 @@ TEST_F(LocalStorageTest, LocalSubConflict) {
EXPECT_CALL(network, Subscribe(_, wpi::SpanEq({std::string{"foo"}}),
IsDefaultPubSubOptions()));
EXPECT_CALL(logger, Call(NT_LOG_INFO, _, _,
"local subscribe to 'foo' disabled due to type "
"mismatch (wanted 'int', published as 'boolean')"));
EXPECT_CALL(logger,
Call(NT_LOG_INFO, _, _,
std::string_view{
"local subscribe to 'foo' disabled due to type "
"mismatch (wanted 'int', published as 'boolean')"}));
storage.Subscribe(fooTopic, NT_INTEGER, "int", {});
}
@@ -350,9 +356,11 @@ TEST_F(LocalStorageTest, RemotePubConflict) {
storage.Publish(fooTopic, NT_BOOLEAN, "boolean", {}, {});
EXPECT_CALL(logger, Call(NT_LOG_INFO, _, _,
"network announce of 'foo' overriding local publish "
"(was 'boolean', now 'int')"));
EXPECT_CALL(logger,
Call(NT_LOG_INFO, _, _,
std::string_view{
"network announce of 'foo' overriding local publish "
"(was 'boolean', now 'int')"}));
storage.NetworkAnnounce("foo", "int", wpi::json::object(), {});
@@ -476,11 +484,10 @@ TEST_F(LocalStorageTest, SetValueEmptyUntypedEntry) {
}
TEST_F(LocalStorageTest, PublishUntyped) {
EXPECT_CALL(
logger,
Call(
NT_LOG_ERROR, _, _,
"cannot publish 'foo' with an unassigned type or empty type string"));
EXPECT_CALL(logger,
Call(NT_LOG_ERROR, _, _,
std::string_view{"cannot publish 'foo' with an unassigned "
"type or empty type string"}));
EXPECT_EQ(storage.Publish(fooTopic, NT_UNASSIGNED, "", {}, {}), 0u);
}
@@ -697,8 +704,9 @@ void LocalStorageNumberVariantsTest::CreateSubscriber(
void LocalStorageNumberVariantsTest::CreateSubscribers() {
EXPECT_CALL(logger,
Call(NT_LOG_INFO, _, _,
"local subscribe to 'foo' disabled due to type "
"mismatch (wanted 'boolean', published as 'double')"));
std::string_view{
"local subscribe to 'foo' disabled due to type "
"mismatch (wanted 'boolean', published as 'double')"}));
CreateSubscriber(&sub1, "subDouble", NT_DOUBLE, "double");
CreateSubscriber(&sub2, "subInteger", NT_INTEGER, "int");
CreateSubscriber(&sub3, "subFloat", NT_FLOAT, "float");
@@ -708,10 +716,12 @@ void LocalStorageNumberVariantsTest::CreateSubscribers() {
}
void LocalStorageNumberVariantsTest::CreateSubscribersArray() {
EXPECT_CALL(logger,
Call(NT_LOG_INFO, _, _,
"local subscribe to 'foo' disabled due to type "
"mismatch (wanted 'boolean[]', published as 'double[]')"));
EXPECT_CALL(
logger,
Call(NT_LOG_INFO, _, _,
std::string_view{
"local subscribe to 'foo' disabled due to type "
"mismatch (wanted 'boolean[]', published as 'double[]')"}));
CreateSubscriber(&sub1, "subDouble", NT_DOUBLE_ARRAY, "double[]");
CreateSubscriber(&sub2, "subInteger", NT_INTEGER_ARRAY, "int[]");
CreateSubscriber(&sub3, "subFloat", NT_FLOAT_ARRAY, "float[]");

View File

@@ -46,7 +46,7 @@ TEST_F(TableListenerTest, AddListener) {
MockTableEventListener listener;
table->AddListener(NT_EVENT_TOPIC | NT_EVENT_IMMEDIATE,
listener.AsStdFunction());
EXPECT_CALL(listener, Call(table.get(), "foovalue", _));
EXPECT_CALL(listener, Call(table.get(), std::string_view{"foovalue"}, _));
PublishTopics();
EXPECT_TRUE(m_inst.WaitForListenerQueue(1.0));
}
@@ -55,7 +55,7 @@ TEST_F(TableListenerTest, AddSubTableListener) {
auto table = m_inst.GetTable("/foo");
MockSubTableListener listener;
table->AddSubTableListener(listener.AsStdFunction());
EXPECT_CALL(listener, Call(table.get(), "bar", _));
EXPECT_CALL(listener, Call(table.get(), std::string_view{"bar"}, _));
PublishTopics();
EXPECT_TRUE(m_inst.WaitForListenerQueue(1.0));
}

View File

@@ -33,6 +33,7 @@ using ::testing::Field;
using ::testing::IsEmpty;
using ::testing::Property;
using ::testing::Return;
using ::testing::StrEq;
using MockSetPeriodicFunc = ::testing::MockFunction<void(uint32_t repeatMs)>;
using MockConnected3Func =
@@ -127,12 +128,15 @@ TEST_F(ServerImplTest, PublishLocal) {
NT_Topic topicHandle3 = nt::Handle{0, 3, nt::Handle::kTopic};
{
::testing::InSequence seq;
EXPECT_CALL(local, NetworkAnnounce("test", "double", wpi::json::object(),
pubHandle));
EXPECT_CALL(local, NetworkAnnounce("test2", "double", wpi::json::object(),
pubHandle2));
EXPECT_CALL(local, NetworkAnnounce("test3", "double", wpi::json::object(),
pubHandle3));
EXPECT_CALL(local, NetworkAnnounce(std::string_view{"test"},
std::string_view{"double"},
wpi::json::object(), pubHandle));
EXPECT_CALL(local, NetworkAnnounce(std::string_view{"test2"},
std::string_view{"double"},
wpi::json::object(), pubHandle2));
EXPECT_CALL(local, NetworkAnnounce(std::string_view{"test3"},
std::string_view{"double"},
wpi::json::object(), pubHandle3));
}
{
@@ -158,7 +162,7 @@ TEST_F(ServerImplTest, PublishLocal) {
"test", 3, "double", std::nullopt, wpi::json::object()}});
smsgs.emplace_back(net::ServerMessage{net::AnnounceMsg{
"test2", 8, "double", std::nullopt, wpi::json::object()}});
EXPECT_CALL(wire, Text(EncodeText(smsgs))); // SendControl()
EXPECT_CALL(wire, Text(StrEq(EncodeText(smsgs)))); // SendControl()
}
EXPECT_CALL(wire, Flush()); // SendControl()
EXPECT_CALL(wire, Ready()).WillOnce(Return(true)); // SendControl()
@@ -166,7 +170,7 @@ TEST_F(ServerImplTest, PublishLocal) {
std::vector<net::ServerMessage> smsgs;
smsgs.emplace_back(net::ServerMessage{net::AnnounceMsg{
"test3", 11, "double", std::nullopt, wpi::json::object()}});
EXPECT_CALL(wire, Text(EncodeText(smsgs))); // SendControl()
EXPECT_CALL(wire, Text(StrEq(EncodeText(smsgs)))); // SendControl()
}
EXPECT_CALL(wire, Flush()); // SendControl()
}
@@ -207,8 +211,9 @@ TEST_F(ServerImplTest, ClientSubTopicOnlyThenValue) {
server.SetLocal(&local);
NT_Publisher pubHandle = nt::Handle{0, 1, nt::Handle::kPublisher};
NT_Topic topicHandle = nt::Handle{0, 1, nt::Handle::kTopic};
EXPECT_CALL(
local, NetworkAnnounce("test", "double", wpi::json::object(), pubHandle));
EXPECT_CALL(local, NetworkAnnounce(std::string_view{"test"},
std::string_view{"double"},
wpi::json::object(), pubHandle));
{
std::vector<net::ClientMessage> msgs;
@@ -231,7 +236,7 @@ TEST_F(ServerImplTest, ClientSubTopicOnlyThenValue) {
std::vector<net::ServerMessage> smsgs;
smsgs.emplace_back(net::ServerMessage{net::AnnounceMsg{
"test", 3, "double", std::nullopt, wpi::json::object()}});
EXPECT_CALL(wire, Text(EncodeText(smsgs))); // SendValues()
EXPECT_CALL(wire, Text(StrEq(EncodeText(smsgs)))); // SendValues()
}
EXPECT_CALL(wire, Flush()); // SendValues()
EXPECT_CALL(setPeriodic, Call(100)); // ClientSubscribe()
@@ -289,8 +294,9 @@ TEST_F(ServerImplTest, ZeroTimestampNegativeTime) {
Value value = Value::MakeDouble(5, -10);
{
::testing::InSequence seq;
EXPECT_CALL(local, NetworkAnnounce("test", "double", wpi::json::object(),
pubHandle))
EXPECT_CALL(local, NetworkAnnounce(std::string_view{"test"},
std::string_view{"double"},
wpi::json::object(), pubHandle))
.WillOnce(Return(topicHandle));
EXPECT_CALL(local, NetworkSetValue(topicHandle, defaultValue));
EXPECT_CALL(local, NetworkSetValue(topicHandle, value));

View File

@@ -19,6 +19,7 @@ endif()
add_executable(outlineviewer ${outlineviewer_src} ${outlineviewer_resources_src} ${outlineviewer_rc} ${APP_ICON_MACOSX})
wpilib_link_macos_gui(outlineviewer)
wpilib_target_warnings(outlineviewer)
target_link_libraries(outlineviewer libglassnt libglass)
if (WIN32)

View File

@@ -35,6 +35,7 @@ endif()
add_executable(wpiguidev src/dev/native/cpp/main.cpp)
wpilib_link_macos_gui(wpiguidev)
wpilib_target_warnings(wpiguidev)
target_link_libraries(wpiguidev wpigui)
install(TARGETS wpigui EXPORT wpigui)