diff mbox series

[2/3] GIT-BUILD-OPTIONS: wire up NO_GITWEB option

Message ID 20241227-b4-pks-meson-wo-gitweb-v1-2-14ca8515bb3b@pks.im (mailing list archive)
State New
Headers show
Series t: fix tests with NO_GITWEB=YesPlease | expand

Commit Message

Patrick Steinhardt Dec. 27, 2024, 12:10 p.m. UTC
Building our "gitweb" interface is optional in our Makefile and in Meson
and not wired up at all with CMake, but disabling it causes a couple of
tests in the t950* range that pull in "t/lib-gitweb.sh". This is because
the test library knows to execute gitweb-tests based on whether or not
Perl is available, but we may have Perl available and still end up not
building gitweb e.g. with `make test NO_GITWEB=YesPlease`.

Fix this issue by wiring up a new "NO_GITWEB" build option so that we
can skip these tests in case gitweb is not built.

Note that this new build option requires us to move the configuration of
GIT-BUILD-OPTIONS to a later point in our Meson build instructions. But
as that file is only consumed by our tests at runtime this change does
not cause any issues.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 GIT-BUILD-OPTIONS.in                |  1 +
 Makefile                            |  1 +
 contrib/buildsystems/CMakeLists.txt |  1 +
 meson.build                         | 59 +++++++++++++++++++------------------
 t/lib-gitweb.sh                     |  5 ++++
 t/test-lib.sh                       |  1 +
 6 files changed, 40 insertions(+), 28 deletions(-)
diff mbox series

Patch

diff --git a/GIT-BUILD-OPTIONS.in b/GIT-BUILD-OPTIONS.in
index 162cc391903c911383fb0fb358589b4cee4b64aa..edff75ae16be90e21a0e9fc5df16a6605439f907 100644
--- a/GIT-BUILD-OPTIONS.in
+++ b/GIT-BUILD-OPTIONS.in
@@ -24,6 +24,7 @@  LOCALEDIR=@LOCALEDIR@
 NO_CURL=@NO_CURL@
 NO_EXPAT=@NO_EXPAT@
 NO_GETTEXT=@NO_GETTEXT@
+NO_GITWEB=@NO_GITWEB@
 NO_ICONV=@NO_ICONV@
 NO_PERL=@NO_PERL@
 NO_PERL_CPAN_FALLBACKS=@NO_PERL_CPAN_FALLBACKS@
diff --git a/Makefile b/Makefile
index f80e70702fcd8df884c7634344cc4ae23d2cb605..97e8385b6643b963c54affb3ae621fc93fad28b5 100644
--- a/Makefile
+++ b/Makefile
@@ -3171,6 +3171,7 @@  GIT-BUILD-OPTIONS: FORCE
 		-e "s|@NO_CURL@|\'$(NO_CURL)\'|" \
 		-e "s|@NO_EXPAT@|\'$(NO_EXPAT)\'|" \
 		-e "s|@NO_GETTEXT@|\'$(NO_GETTEXT)\'|" \
+		-e "s|@NO_GITWEB@|\'$(NO_GITWEB)\'|" \
 		-e "s|@NO_ICONV@|\'$(NO_ICONV)\'|" \
 		-e "s|@NO_PERL@|\'$(NO_PERL)\'|" \
 		-e "s|@NO_PERL_CPAN_FALLBACKS@|\'$(NO_PERL_CPAN_FALLBACKS_SQ)\'|" \
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index f45407b060221bf900fd0a19a315f0d0dce23147..10dc54fdcb647bbeeffb4eff6f18d10337b49873 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -1184,6 +1184,7 @@  string(REPLACE "@LOCALEDIR@" "'${LOCALEDIR}'" git_build_options "${git_build_opt
 string(REPLACE "@NO_CURL@" "${NO_CURL}" git_build_options "${git_build_options}")
 string(REPLACE "@NO_EXPAT@" "${NO_EXPAT}" git_build_options "${git_build_options}")
 string(REPLACE "@NO_GETTEXT@" "${NO_GETTEXT}" git_build_options "${git_build_options}")
+string(REPLACE "@NO_GITWEB@" "1" git_build_options "${git_build_options}")
 string(REPLACE "@NO_ICONV@" "${NO_ICONV}" git_build_options "${git_build_options}")
 string(REPLACE "@NO_PERL@" "${NO_PERL}" git_build_options "${git_build_options}")
 string(REPLACE "@NO_PERL_CPAN_FALLBACKS@" "" git_build_options "${git_build_options}")
diff --git a/meson.build b/meson.build
index a0654a3f244adc19db434e01ca6b3709fb8ff8af..3e57793862e5fc15685b5f0fac7f7223af7bef1f 100644
--- a/meson.build
+++ b/meson.build
@@ -1456,34 +1456,6 @@  else
   build_options_config.set('RUNTIME_PREFIX', 'false')
 endif
 
-foreach key, value : {
-  'DIFF': diff.full_path(),
-  'GIT_TEST_CMP': diff.full_path() + ' -u',
-  'GIT_TEST_GITPERLLIB': meson.project_build_root() / 'perl',
-  'GIT_TEST_MERGE_TOOLS_DIR': meson.project_source_root() / 'mergetools',
-  'GIT_TEST_POPATH': meson.project_source_root() / 'po',
-  'GIT_TEST_TEMPLATE_DIR': meson.project_build_root() / 'templates',
-  'GIT_TEST_TEXTDOMAINDIR': meson.project_build_root() / 'po',
-  'PAGER_ENV': get_option('pager_environment'),
-  'PERL_PATH': perl.found() ? perl.full_path() : '',
-  'PYTHON_PATH': python.found () ? python.full_path() : '',
-  'SHELL_PATH': shell.full_path(),
-  'TAR': tar.full_path(),
-  'TEST_OUTPUT_DIRECTORY': test_output_directory,
-  'TEST_SHELL_PATH': shell.full_path(),
-}
-  if value != '' and cygpath.found()
-    value = run_command(cygpath, value, check: true).stdout().strip()
-  endif
-  build_options_config.set_quoted(key, value)
-endforeach
-
-configure_file(
-  input: 'GIT-BUILD-OPTIONS.in',
-  output: 'GIT-BUILD-OPTIONS',
-  configuration: build_options_config,
-)
-
 git_version_file = custom_target(
   command: [
     shell,
@@ -1893,6 +1865,9 @@  subdir('contrib')
 gitweb_option = get_option('gitweb').disable_auto_if(not perl.found())
 if gitweb_option.enabled()
   subdir('gitweb')
+  build_options_config.set('NO_GITWEB', '')
+else
+  build_options_config.set('NO_GITWEB', '1')
 endif
 
 subdir('templates')
@@ -1909,6 +1884,34 @@  if get_option('docs') != []
   subdir('Documentation')
 endif
 
+foreach key, value : {
+  'DIFF': diff.full_path(),
+  'GIT_TEST_CMP': diff.full_path() + ' -u',
+  'GIT_TEST_GITPERLLIB': meson.project_build_root() / 'perl',
+  'GIT_TEST_MERGE_TOOLS_DIR': meson.project_source_root() / 'mergetools',
+  'GIT_TEST_POPATH': meson.project_source_root() / 'po',
+  'GIT_TEST_TEMPLATE_DIR': meson.project_build_root() / 'templates',
+  'GIT_TEST_TEXTDOMAINDIR': meson.project_build_root() / 'po',
+  'PAGER_ENV': get_option('pager_environment'),
+  'PERL_PATH': perl.found() ? perl.full_path() : '',
+  'PYTHON_PATH': python.found () ? python.full_path() : '',
+  'SHELL_PATH': shell.full_path(),
+  'TAR': tar.full_path(),
+  'TEST_OUTPUT_DIRECTORY': test_output_directory,
+  'TEST_SHELL_PATH': shell.full_path(),
+}
+  if value != '' and cygpath.found()
+    value = run_command(cygpath, value, check: true).stdout().strip()
+  endif
+  build_options_config.set_quoted(key, value)
+endforeach
+
+configure_file(
+  input: 'GIT-BUILD-OPTIONS.in',
+  output: 'GIT-BUILD-OPTIONS',
+  configuration: build_options_config,
+)
+
 summary({
   'curl': curl.found(),
   'expat': expat.found(),
diff --git a/t/lib-gitweb.sh b/t/lib-gitweb.sh
index 7f9808ec2024d62edc3a3f1c01fb255d0fd37cb2..a6e3dd11b3552a477c84c974db29d902fd87183f 100644
--- a/t/lib-gitweb.sh
+++ b/t/lib-gitweb.sh
@@ -105,6 +105,11 @@  if ! test_have_prereq PERL; then
 	test_done
 fi
 
+if ! test_have_prereq GITWEB; then
+	skip_all='skipping gitweb tests, gitweb not available'
+	test_done
+fi
+
 perl -MEncode -e '$e="";decode_utf8($e, Encode::FB_CROAK)' >/dev/null 2>&1 || {
 	skip_all='skipping gitweb tests, perl version is too old'
 	test_done
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 62dfcc4aaf959d0cf066d07663d939e14f92485c..1a67adb20764d60a70ebfde6df52a0fbd3bf72ee 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1687,6 +1687,7 @@  esac
 
 ( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1
 test -z "$NO_CURL" && test_set_prereq LIBCURL
+test -z "$NO_GITWEB" && test_set_prereq GITWEB
 test -z "$NO_ICONV" && test_set_prereq ICONV
 test -z "$NO_PERL" && test_set_prereq PERL
 test -z "$NO_PTHREADS" && test_set_prereq PTHREADS