Skip to content

cmake, test: Enable running individual functional tests - #226

Merged
hebasto merged 3 commits into
cmake-stagingfrom
240608-cmake-FY
Jun 11, 2024
Merged

hebasto merged 3 commits into
cmake-stagingfrom
240608-cmake-FY

Conversation

@hebasto

@hebasto hebasto commented Jun 8, 2024 •

Copy link
Copy Markdown
Owner

Resolves #146.

It should be possible to run all functional tests directly.

Done.

Furthermore, these should be symlinked as making changes to the test in the source directory should result in the executed test also changing without needing a rebuild.

Done.

For example, trying to run test/functional/wallet_basic.py from the build dir is not possible.

Works as expected now.

Create functional test symlinks.
@hebasto hebasto added enhancement New feature or request tests Tests, benchmarks, fuzzing, CI etc labels Jun 8, 2024
@hebasto
hebasto force-pushed the 240608-cmake-FY branch 3 times, most recently from ae2b782 to 4d0e0fd Compare June 8, 2024 22:46
@maflcko

maflcko commented Jun 9, 2024

Copy link
Copy Markdown

Would it make sense to do the functional test framework changes on top of the autotools build system as well (before cmake), considering out-of-tree builds?

@hebasto

hebasto commented Jun 9, 2024

Copy link
Copy Markdown
Owner Author

cc @achow101

@hebasto

hebasto commented Jun 9, 2024

Copy link
Copy Markdown
Owner Author

Would it make sense to do the functional test framework changes on top of the autotools build system as well (before cmake), considering out-of-tree builds?

Well, creating a symlink for each functional test does not look trivial for configure.ac.

parser.add_argument("--noshutdown", dest="noshutdown", default=False, action="store_true",
help="Don't stop bitcoinds after the test execution")
parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../../cache"),
parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(test_file) + "/../../cache"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this correct? Previously, the path was test/functional/test_framework/../../cache (aka test/cache), now it is test/functional/../../cache (aka cache).
Why not:

Suggested change
parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(test_file) + "/../../cache"),
parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(__file__) + "/../../cache"),

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Is this correct?

It is (mostly; see the last paragraph of this comment).

now it is test/functional/../../cache (aka cache).

That is correct with a clarification. It is build_dir/cache, not source_dir/cache.

Why not:

Suggested change
parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(test_file) + "/../../cache"),
parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(__file__) + "/../../cache"),

Using __file__ won't work because it ends in the source tree on POSIX systems. For more details, please refer to https://discuss.python.org/t/symlink-resolution-in-starting-script-path/36537.

Perhaps, one path level can be skipped:

Suggested change
parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(test_file) + "/../../cache"),
parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(test_file) + "/../cache"),

which ends in the build_dir/test/cache path.

@maflcko maflcko Jun 9, 2024 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using __file__ won't work because it ends in the source tree on POSIX systems. For more details, please refer to https://discuss.python.org/t/symlink-resolution-in-starting-script-path/36537.

Ah, so the test framework changes could be split up into a separate pull against upstream master, because this affects all symlinks (whether created by cmake or not) on POSIX? I am just thinking how to split the massive cmake change into smaller blobs that can be landed/reviewed independently and in advance.

Perhaps, one path level can be skipped:

Yes, this is what I was trying to suggest. Previously the cache was in test/cache and now it should be as well, no?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Perhaps, one path level can be skipped:

Yes, this is what I was trying to suggest. Previously the cache was in test/cache and now it should be as well, no?

Thanks! Done.

hebasto added 2 commits June 9, 2024 19:13
In CMake-based build system (1) `config.ini` is created in the build
directory, and (2) `cache` must also be created in the same directory.

This change enables running individual functional tests from the build
directory.
@hebasto
hebasto force-pushed the 240608-cmake-FY branch from f45d4d7 to 7e94254 Compare June 9, 2024 18:13

@maflcko maflcko left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

lgtm

@hebasto
hebasto merged commit 8975005 into cmake-staging Jun 11, 2024
@achow101

Copy link
Copy Markdown

post merge ACK

Tested and every test file looks to be correctly symlinked. Also called each test file individually and all worked as expected.

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

Labels

enhancement New feature or request tests Tests, benchmarks, fuzzing, CI etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cmake: Individual functional tests cannot be run

3 participants