Skip to content

tests: simplify passing srcdir to tests - #1032

Closed
vszakats wants to merge 7 commits into
libssh2:masterfrom
vszakats:reduce-srcdir-tricks
Closed

vszakats wants to merge 7 commits into
libssh2:masterfrom
vszakats:reduce-srcdir-tricks

Conversation

@vszakats

@vszakats vszakats commented May 5, 2023 •

Copy link
Copy Markdown
Member

Before this patch libssh2 used a variety of solutions to pass the source
directory to tests: FIXTURE_WORKDIR build-time macro (cmake),
FIXTURE_WORKDIR envvar (unused), setting srcdir manually
(autotools), setting current directory (cmake), and also builddir
envvar (autotools) for passing current working dir to mansyntax.sh.

This patch reduces this to using existing srcdir with autotools and
setting it ourselves in CMake. This was mostly enabled by this recent
patch: 4c9ed51

Details:

Closes #1032

@vszakats vszakats added the tests label May 5, 2023
@vszakats
vszakats marked this pull request as draft May 5, 2023 01:29
@vszakats
vszakats force-pushed the reduce-srcdir-tricks branch 2 times, most recently from 9f233c9 to 7b2fffb Compare May 5, 2023 14:47
vszakats added a commit that referenced this pull request May 5, 2023
After deleting the `bcrypt.h` check, no check remained. Restore
a `WIN32` check here to ensure WinCNG is not enabled outside Windows.

Follow-up to 1289033

Tested-in #1032
vszakats added 7 commits May 5, 2023 17:26
This should be unnecessary after
  4c9ed51 libssh2#801,
that prefixes referenced input filenames with the `srcdir` envvar.

The `srcdir` envvar was already exported by autotools, and now we're
also setting it from CMake.
`WORKING_DIRECTORY` is no longer necessary, after passing `srcdir`
to all tests, so they can find our source tree and keys/etc in it
regardless of the current directory.

Also this past commit hints that `WORKING_DIRECTORY` wasn't always
working for this purpose as expected:
  "tests: Xcode doesn't obey CMake's test working directory"
Ref: libssh2@10a5cbf
Added in Added in 13f8add (2015-07-02)

It seems this wasn't necessary to make the above fix work, and
`mansyntax.sh` is able to figure out the build workdir by reading
$PWD. Our out-of-tree and `make distcheck` CI builds also work
without it.

Let us know if there is a scenario we're missing and needs this.
@vszakats
vszakats force-pushed the reduce-srcdir-tricks branch from f24dfa7 to cce84a0 Compare May 5, 2023 17:27
@vszakats
vszakats marked this pull request as ready for review May 5, 2023 17:32
@vszakats vszakats changed the title tests: try reducing workdir/srcdir passing methods tests: simplify passing srcdir to tests May 5, 2023
@vszakats vszakats closed this in cdd7fc0 May 5, 2023
@vszakats
vszakats deleted the reduce-srcdir-tricks branch May 5, 2023 20:40
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
After deleting the `bcrypt.h` check, no check remained. Restore
a `WIN32` check here to ensure WinCNG is not enabled outside Windows.

Follow-up to 1289033

Tested-in libssh2#1032
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
Before this patch libssh2 used a variety of solutions to pass the source
directory to tests: `FIXTURE_WORKDIR` build-time macro (cmake),
`FIXTURE_WORKDIR` envvar (unused), setting `srcdir` manually
(autotools), setting current directory (cmake), and also `builddir`
envvar (autotools) for passing current working dir to `mansyntax.sh`.

This patch reduces this to using existing `srcdir` with autotools and
setting it ourselves in CMake. This was mostly enabled by this recent
patch: 4c9ed51

Details:

- cmake: replace baked-in `FIXTURE_WORKDIR` macro with env.

  Added in 54bef4c libssh2#198 (2018-03-21)

- rename `FIXTURE_WORKDIR` to `srcdir`, to match autotools.

- cmake: add missing `srcdir` for algo and sshd tests.

- session_fixture: stop `chdir()`-ing, rely on prefixing with `srcdir`.

  Changing current directory should be unnecessary after
    4c9ed51 libssh2#801 (2023-02-24),
  that prefixes referenced input filenames with the `srcdir` envvar.

  The `srcdir` envvar was already exported by autotools, and now we're
  also setting it from CMake.

- cmake: stop setting `WORKING_DIRECTORY`, rely on `srcdir` env.

  `WORKING_DIRECTORY` is no longer necessary, after passing `srcdir` to
  all tests, so they can find our source tree and keys/etc in it
  regardless of the current directory.

  Also this past commit hints that `WORKING_DIRECTORY` wasn't always
  working for this purpose as expected:
    "tests: Xcode doesn't obey CMake's test working directory"
  Ref: libssh2@10a5cbf

- autotools: delete explicit `srcdir` for test env.

  Added in 13f8add (2015-07-02)

  automake documents `srcdir` as exported to the test environment:
  https://github.com/autotools-mirror/automake/blob/c04c4e8856e3c933239959ce18e16599fcc04a8b/doc/automake.texi#L9302-L9304
  https://www.gnu.org/software/automake/manual/html_node/Scripts_002dbased-Testsuites.html
  It's mentioned in the docs back in 1997 and got a regression test in
  2012. We can safely assume it to be available without setting it
  ourselves.

- autotools: delete explicit `builddir`.

  Added in 13f8add (2015-07-02)

  It seems this wasn't necessary to make the above fix work, and
  `mansyntax.sh` is able to figure out the build workdir by reading
  `$PWD`. Our out-of-tree and `make distcheck` CI builds also work
  without it.

  Let us know if there is a scenario we're missing and needs this.

Closes libssh2#1032
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant