Skip to content

Commit

Permalink
libzeep 6.0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshitakaMo committed Aug 11, 2024
1 parent a287bb8 commit 00082f3
Showing 1 changed file with 79 additions and 2 deletions.
81 changes: 79 additions & 2 deletions Formula/libzeep.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class Libzeep < Formula
end

depends_on "cmake" => :build
depends_on "pkg-config" => [:build, :test]
depends_on "boost"
depends_on "howard-hinnant-date"

Expand Down Expand Up @@ -41,6 +40,84 @@ def install
end

test do
assert_match "-I#{include}", shell_output("pkg-config --cflags libzeep")
(testpath/"test.cpp").write <<~EOS
#include <iostream>
#include <zeep/http/controller.hpp>
#include <zeep/http/daemon.hpp>
namespace zh = zeep::http;
class hello_controller : public zh::controller
{
public:
/* Specify the root path as prefix, will handle any request URI */
hello_controller()
: controller("/")
{
}
bool handle_request([[maybe_unused]] zh::request &req, zh::reply &rep)
{
/* Construct a simple reply with status OK (200) and content string */
rep = zh::reply::stock_reply(zh::ok);
rep.set_content("Hello", "text/plain");
return true;
}
};
int main(int argc, char *const argv[])
{
using namespace std::literals;
if (argc != 2)
{
std::cout << "No command specified, use of of start, stop, status or reload";
exit(1);
}
// --------------------------------------------------------------------
std::string command = argv[1];
zh::daemon server([&]()
{
auto s = new zeep::http::server(/*sc*/);
s->add_controller(new hello_controller());
return s; },
"hello-daemon");
int result;
if (command == "start")
{
std::string address = "127.0.0.1";
unsigned short port = 10330;
std::string user = "www-data";
std::cout << "starting server at http://" << address << ":" << port << "";
result = server.start(address, port, 1, 16, user);
}
else if (command == "stop")
result = server.stop();
else if (command == "status")
result = server.status();
else if (command == "reload")
result = server.reload();
else
{
std::clog << "Invalid command";
result = 1;
}
return result;
}
EOS
system ENV.cxx, "test.cpp", "-o", "test",

Check failure on line 117 in Formula/libzeep.rb

View workflow job for this annotation

GitHub Actions / build-bottles (macos-14)

Layout/ExtraSpacing: Unnecessary spacing detected.

Check failure on line 117 in Formula/libzeep.rb

View workflow job for this annotation

GitHub Actions / build-bottles (macos-13)

Layout/ExtraSpacing: Unnecessary spacing detected.

Check failure on line 117 in Formula/libzeep.rb

View workflow job for this annotation

GitHub Actions / build-bottles (ubuntu-latest)

Layout/ExtraSpacing: Unnecessary spacing detected.
"-std=c++17", "-I#{include}",
"-I#{Formula["boost"].opt_include}",
"-L#{lib}", "-lzeep"
assert_match "server is not running", shell_output("./test status 2>&1", 1)
end
end

0 comments on commit 00082f3

Please sign in to comment.