Skip to content

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

Merged
etr merged 3 commits into
etr:masterfrom
bcsgh:bcsgh/test-flexibility
Apr 10, 2023
Merged

etr merged 3 commits into
etr:masterfrom
bcsgh:bcsgh/test-flexibility

Conversation

@bcsgh

@bcsgh bcsgh commented Apr 4, 2023 •

Copy link
Copy Markdown
Contributor

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.

bcsgh added 2 commits April 3, 2023 20:11
…on't have port 8080 open or where the test don't run on a 'normal' file system (e.g. a sandbox full of symlinks).
@bcsgh
bcsgh marked this pull request as ready for review April 4, 2023 04:39
Comment thread test/integ/basic.cpp Outdated
Comment thread test/integ/basic.cpp
Comment on lines +317 to +318
#define STR2(p) #p
#define STR(p) STR2(p)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why do we need the proxy definition of STR(p)? Cannot we just simply have what's on line 317 and name that STR(p) ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Without the extra layer, the macro expands to the literal argument (PORT) rather than what that argument expands to:

A quick demo of how things expand: https://godbolt.org/z/Mz4eexzb5

See also: https://gcc.gnu.org/onlinedocs/gcc-4.8.5/cpp/Stringification.html

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Makes sense, thanks.

@etr

etr commented Apr 6, 2023

Copy link
Copy Markdown
Owner

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

bcsgh commented Apr 6, 2023

Copy link
Copy Markdown
Contributor Author

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

@etr
etr merged commit 2dae151 into etr:master Apr 10, 2023
@etr

etr commented Apr 10, 2023

Copy link
Copy Markdown
Owner

Looks good. Merged it in.

@bcsgh
bcsgh deleted the bcsgh/test-flexibility branch April 11, 2023 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants