mwrap (Perl version) user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [PATCH] t/httpd.t: needs sqlite3 3.32.0+ for `.import --csv'
@ 2023-01-09  0:01 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2023-01-09  0:01 UTC (permalink / raw)
  To: mwrap-perl

Just disable the test if CSV import doesn't work with the
currently-installed sqlite3.
---
 t/httpd.t | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/t/httpd.t b/t/httpd.t
index 7746837..8f56f64 100644
--- a/t/httpd.t
+++ b/t/httpd.t
@@ -135,19 +135,28 @@ SKIP: {
 
 SKIP: {
 	skip 'no reset w/o curl --unix-socket', 1 if !$curl_unix;
-
+	my ($sqlite_v) = (`sqlite3 --version` =~ /([\d+\.]+)/);
+	if ($?) {
+		diag 'sqlite3 missing or broken';
+		$sqlite_v = 0;
+	} else {
+		my @v = split(/\./, $sqlite_v);
+		$sqlite_v = ($v[0] << 16) | ($v[1] << 8) | $v[2];
+		diag 'sqlite_v='.sprintf('0x%x', $sqlite_v);
+	}
 	$rc = system(@curl, "http://0/$pid/each/100.csv");
 	is($rc, 0, '.csv retrieved') or skip 'CSV failed', 1;
 	my $db = "$mwrap_tmp/t.sqlite3";
-	$rc = system(qw(sqlite3), $db, ".import --csv $cout mwrap_each");
-	if ($rc == -1) {
-		diag 'sqlite3 missing';
-	} else {
+
+	if ($sqlite_v >= 0x32000) {
+		$rc = system(qw(sqlite3), $db,".import --csv $cout mwrap_each");
 		is($rc, 0, 'sqlite3 import');
 		my $n = `sqlite3 $db 'SELECT COUNT(*) FROM mwrap_each'`;
 		is($?, 0, 'sqlite3 count');
 		my $exp = split(/\n/, slurp($cout));
 		is($n + 1, $exp, 'imported all rows into sqlite');
+	} else {
+		diag "sqlite 3.32.0+ needed for `.import --csv'";
 	}
 
 	$rc = system(@curl, qw(-d x=y), "http://0/$pid/reset");

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-09  0:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09  0:01 [PATCH] t/httpd.t: needs sqlite3 3.32.0+ for `.import --csv' Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mwrap-perl.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).