etr / libhttpserver

C++ library for creating an embedded Rest HTTP server (and more)
GNU Lesser General Public License v2.1
893 stars 186 forks source link

Modify some integration tests to allow them to pass on more limited systems #307

Closed bcsgh closed 1 year ago

bcsgh commented 1 year ago

Several integration tests require that port 8080 be available. As this is one of the more common alternative HTTP ports, it is likely to be unavailable. A bit of pre-processor hacking allows the build to select a different port if needed.

Another issue is that tests that use httpserver::file_response require that the expected path be an actual file. Some build environments (the provoking case is where I need to use libhttpserver from a Bazel build, which uses a sandbox built from symlinks, and I need to also build and run the test under bazel to ensure that build is also correct)


NOTE: I don't know how to make Codacy/cppcheck happy with the new config HTTPSERVER_PORT (it seems to already be fine with the other config: HTTPSERVER_NO_LOCAL_FS) . The most useful thing I've found is this but I don't know where to go from there.

Help or suggestions would be appreciated.

etr commented 1 year ago

NOTE: I don't know how to make Codacy/cppcheck happy with the new config HTTPSERVER_PORT (it seems to already be fine with the other config: HTTPSERVER_NO_LOCAL_FS) . The most useful thing I've found is this but I don't know where to go from there.

I disabled the check for the test files, but codacy even on re-runs keeps complaining about the issue. I suspect that it keeps the settings it had at the time the PR was created when evaluating a PR. I'll manually check codacy before merging this change to see if there are other issues, but in regard to the definition of the port parameter, don't worry about it.

bcsgh commented 1 year ago

Looks like codacy caches config per commit rather than per PR, adding a new commit seems to make it start over. :-)

etr commented 1 year ago

Looks good. Merged it in.