From c36c4ddae25337ae80ac9156de073ca4f7f79eb8 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Nov 2024 15:20:36 -0500 Subject: [PATCH 1/7] ci: run one set of tests with a release build This ensures that no tests fail due to differences between release and debug builds. The release build-type check is now unnecessary, too, so remove it. --- .github/workflows/test.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2a7b036e4d..1f83a875d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -106,7 +106,7 @@ jobs: [ { runner: ubuntu-24.04, os: ubuntu, flavor: asan, cc: clang, flags: -D ENABLE_ASAN_UBSAN=ON }, { runner: ubuntu-24.04, os: ubuntu, flavor: tsan, cc: clang, flags: -D ENABLE_TSAN=ON }, - { runner: ubuntu-24.04, os: ubuntu, cc: gcc }, + { runner: ubuntu-24.04, os: ubuntu, flavor: release, cc: gcc, flags: -D CMAKE_BUILD_TYPE=Release }, { runner: macos-13, os: macos, flavor: intel, cc: clang, flags: -D CMAKE_FIND_FRAMEWORK=NEVER, deps_flags: -D CMAKE_FIND_FRAMEWORK=NEVER }, { runner: macos-15, os: macos, flavor: arm, cc: clang, flags: -D CMAKE_FIND_FRAMEWORK=NEVER, deps_flags: -D CMAKE_FIND_FRAMEWORK=NEVER }, { runner: ubuntu-24.04, os: ubuntu, flavor: puc-lua, cc: gcc, deps_flags: -D USE_BUNDLED_LUAJIT=OFF -D USE_BUNDLED_LUA=ON, flags: -D PREFER_LUA=ON }, @@ -194,7 +194,7 @@ jobs: uses: ./.github/workflows/test_windows.yml # This job tests the following things: - # - Check if Release, MinSizeRel and RelWithDebInfo compiles correctly. + # - Check if MinSizeRel and RelWithDebInfo compiles correctly. # - Test the above build types with the GCC compiler specifically. # Empirically the difference in warning levels between GCC and other # compilers is particularly big. @@ -218,9 +218,6 @@ jobs: - name: Configure run: cmake --preset ci -G "Ninja Multi-Config" - - name: Release - run: cmake --build build --config Release - - name: RelWithDebInfo run: cmake --build build --config RelWithDebInfo From a930b2666e5c11f3b0f2f54058dcd4fe2b815370 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Nov 2024 15:27:52 -0500 Subject: [PATCH 2/7] ci(test): remove the .git directory for Linux Tests should not rely on being run inside a git clone, so the Linux builds cover this use case. The macOS builds will continue running with the .git directory so there's still unix-ish coverage within a git clone. --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1f83a875d1..76d086b139 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -145,6 +145,10 @@ jobs: sudo cpanm -n Neovim::Ext || cat "$HOME/.cpanm/build.log" perl -W -e 'use Neovim::Ext; print $Neovim::Ext::VERSION' + - name: Remove .git directory + if: ${{ matrix.build.os == 'ubuntu' }} + run: cmake -E rm -rf -- .git + - name: Build third-party deps run: | cmake -S cmake.deps --preset ci -D CMAKE_BUILD_TYPE=Debug ${{ matrix.build.deps_flags }} From 584b811aee5ee62c767c6bde38c9af3117259167 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Nov 2024 21:04:50 -0500 Subject: [PATCH 3/7] test(main_spec): use CMakePresets.json instead of .git for root marker --- test/functional/lua/fs_spec.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua index aba02ab01b..b7f47e4aeb 100644 --- a/test/functional/lua/fs_spec.lua +++ b/test/functional/lua/fs_spec.lua @@ -286,14 +286,14 @@ describe('vim.fs', function() end) it('works with a single marker', function() - eq(test_source_path, exec_lua([[return vim.fs.root(0, '.git')]])) + eq(test_source_path, exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]])) end) it('works with multiple markers', function() local bufnr = api.nvim_get_current_buf() eq( vim.fs.joinpath(test_source_path, 'test/functional/fixtures'), - exec_lua([[return vim.fs.root(..., {'CMakeLists.txt', '.git'})]], bufnr) + exec_lua([[return vim.fs.root(..., {'CMakeLists.txt', 'CMakePresets.json'})]], bufnr) ) end) @@ -308,26 +308,26 @@ describe('vim.fs', function() end) it('works with a filename argument', function() - eq(test_source_path, exec_lua([[return vim.fs.root(..., '.git')]], nvim_prog)) + eq(test_source_path, exec_lua([[return vim.fs.root(..., 'CMakePresets.json')]], nvim_prog)) end) it('works with a relative path', function() eq( test_source_path, - exec_lua([[return vim.fs.root(..., '.git')]], vim.fs.basename(nvim_prog)) + exec_lua([[return vim.fs.root(..., 'CMakePresets.json')]], vim.fs.basename(nvim_prog)) ) end) it('uses cwd for unnamed buffers', function() command('new') - eq(test_source_path, exec_lua([[return vim.fs.root(0, '.git')]])) + eq(test_source_path, exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]])) end) it("uses cwd for buffers with non-empty 'buftype'", function() command('new') command('set buftype=nofile') command('file lua://') - eq(test_source_path, exec_lua([[return vim.fs.root(0, '.git')]])) + eq(test_source_path, exec_lua([[return vim.fs.root(0, 'CMakePresets.json')]])) end) end) From 4007c42b77d480e7af94ec0c9377ef1116e12031 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Nov 2024 21:07:28 -0500 Subject: [PATCH 4/7] test(version_spec): expect vim.NIL, not nil, for "build" if not in a git clone --- test/functional/api/version_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/api/version_spec.lua b/test/functional/api/version_spec.lua index 5dad9978b7..da9c6974f7 100644 --- a/test/functional/api/version_spec.lua +++ b/test/functional/api/version_spec.lua @@ -43,7 +43,7 @@ describe("api_info()['version']", function() eq(0, fn.has('nvim-' .. major .. '.' .. minor .. '.' .. (patch + 1))) eq(0, fn.has('nvim-' .. major .. '.' .. (minor + 1) .. '.' .. patch)) eq(0, fn.has('nvim-' .. (major + 1) .. '.' .. minor .. '.' .. patch)) - assert(build == nil or type(build) == 'string') + assert(build == vim.NIL or type(build) == 'string') end) end) From 7781111fefd0e68643dc0c1cce0772bfd810961e Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Nov 2024 22:11:20 -0500 Subject: [PATCH 5/7] test(main_spec): make "nvim -v" test agnostic to build type In release builds, the Compilation: line is omitted so the build is reproducible. Since the "fall-back for $VIM" line is always present, check for that instead. --- test/functional/core/main_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua index a6e917b4b2..c1f94cdf15 100644 --- a/test/functional/core/main_spec.lua +++ b/test/functional/core/main_spec.lua @@ -189,9 +189,9 @@ describe('command-line option', function() it('nvim -v, :version', function() matches('Run ":verbose version"', fn.execute(':version')) - matches('Compilation: .*Run :checkhealth', fn.execute(':verbose version')) + matches('fall%-back for %$VIM: .*Run :checkhealth', fn.execute(':verbose version')) matches('Run "nvim %-V1 %-v"', fn.system({ nvim_prog_abs(), '-v' })) - matches('Compilation: .*Run :checkhealth', fn.system({ nvim_prog_abs(), '-V1', '-v' })) + matches('fall%-back for %$VIM: .*Run :checkhealth', fn.system({ nvim_prog_abs(), '-V1', '-v' })) end) if is_os('win') then From 9695650c0c5629dbf02665357ab5ac12faec346f Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 27 Nov 2024 07:55:55 -0500 Subject: [PATCH 6/7] ci: run tests directly rather than via the Makefile Since the Makefile is not used to build, running the tests via the Makefile causes cmake to reconfigure and revert the release build back to debug. --- .github/workflows/test.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 76d086b139..4729bbbbf7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -159,9 +159,15 @@ jobs: cmake --preset ci -D CMAKE_BUILD_TYPE=Debug -D CMAKE_INSTALL_PREFIX:PATH=$INSTALL_PREFIX ${{ matrix.build.flags }} cmake --build build - - name: ${{ matrix.test }} + - if: ${{ matrix.test == 'oldtest' }} + name: ${{ matrix.test }} timeout-minutes: 20 - run: make ${{ matrix.test }} + run: make -C test/old/testdir NVIM_PRG=$(realpath build)/bin/nvim + + - if: ${{ matrix.test != 'oldtest' }} + name: ${{ matrix.test }} + timeout-minutes: 20 + run: cmake --build build --target ${{ matrix.test }} - name: Install run: | From 694c3992ea060bd461d011711bf3d83df1f9db67 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 3 Dec 2024 06:34:07 -0500 Subject: [PATCH 7/7] test(marktree): expose test functions in release builds In order to run the marktree unit test in release mode, the test functions need to be available even when NDEBUG is defined. Keep the body of marktree_check a nop during release builds, which limits the usefulness of the testing, but at least lets the tests run. --- src/nvim/marktree.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c index 71cc55784f..fbe9737066 100644 --- a/src/nvim/marktree.c +++ b/src/nvim/marktree.c @@ -2330,7 +2330,6 @@ void marktree_check(MarkTree *b) #endif } -#ifndef NDEBUG size_t marktree_check_node(MarkTree *b, MTNode *x, MTPos *last, bool *last_right, const uint32_t *meta_node_ref) { @@ -2485,8 +2484,6 @@ bool mt_recurse_nodes_compare(MTNode *x, PMap(ptr_t) *checked) return true; } -#endif - // TODO(bfredl): kv_print #define GA_PUT(x) ga_concat(ga, (char *)(x)) #define GA_PRINT(fmt, ...) snprintf(buf, sizeof(buf), fmt, __VA_ARGS__); \