From 4ae5ece20f2aea6f3c85feac7e39c18d0c5d0095 Mon Sep 17 00:00:00 2001 From: FreeSlave Date: Sat, 16 Jul 2016 23:58:49 +0300 Subject: [PATCH] 100% coverage for detectors/cache.d --- source/mime/database.d | 12 ++++++++- test/.gitignore | 1 + test/discard/generic-icons | 1 + test/discard/globs | 5 +++- test/discard/globs2 | 5 +++- test/discard/mime.cache | Bin 504 -> 776 bytes test/discard/packages/discard.xml | 16 +++++++++++- test/discard/subclasses | 3 ++- test/discard/types | 5 +++- test/discard/version | 2 +- test/mime/globs | 12 +++++---- test/mime/globs2 | 14 +++++----- test/mime/mime.cache | Bin 5760 -> 5784 bytes test/mime/packages/base.xml | 2 +- test/mime/packages/quake-hl.xml | 2 ++ test/mime/version | 2 +- test/note.txt | 3 +++ test/update-mime-database.c.patch | 42 ++++++++++++++++++++++++++++++ test/update.sh | 4 +-- 19 files changed, 109 insertions(+), 22 deletions(-) create mode 100644 test/.gitignore create mode 100644 test/note.txt create mode 100644 test/update-mime-database.c.patch diff --git a/source/mime/database.d b/source/mime/database.d index ac680ba..0267dff 100644 --- a/source/mime/database.d +++ b/source/mime/database.d @@ -359,7 +359,17 @@ unittest //testing literal assert(database.mimeTypeForFileName("liblist.gam")); - assert(database.mimeTypeForFileName("GNUmakefile")); + assert(database.mimeTypeForFileName("makefile")); + + //testing discard glob + assert(!database.mimeTypeForFileName("GNUmakefile")); + assert(!database.detector.mimeTypeForFileName("GNUmakefile")); + + assert(!database.mimeTypeForFileName("file.qvm3")); + assert(!database.detector.mimeTypeForFileName("file.qvm3")); + + assert(!database.mimeTypeForFileName("model01.sequence")); + assert(!database.detector.mimeTypeForFileName("model01.sequence")); //testing discard magic assert(!database.mimeTypeForData("PAK")); diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..697ae90 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +update-mime-database diff --git a/test/discard/generic-icons b/test/discard/generic-icons index e69de29..d680896 100644 --- a/test/discard/generic-icons +++ b/test/discard/generic-icons @@ -0,0 +1 @@ +application/x-hlmdl-sequence:application-x-hlmdl diff --git a/test/discard/globs b/test/discard/globs index 063dc47..7a119f6 100644 --- a/test/discard/globs +++ b/test/discard/globs @@ -1,4 +1,7 @@ # This file was automatically generated by the # update-mime-database command. DO NOT EDIT! -text/x-gnumakefile:gnumakefile +application/x-hlmdl-sequence:**[0123456789][0123456789].sequence +text/x-makefile:gnumakefile application/java-multimedia-file:*.jmf +text/x-othermakefile:makefile +application/x-qvm:*.qvm3 diff --git a/test/discard/globs2 b/test/discard/globs2 index c617b2d..ad56ece 100644 --- a/test/discard/globs2 +++ b/test/discard/globs2 @@ -1,4 +1,7 @@ # This file was automatically generated by the # update-mime-database command. DO NOT EDIT! -50:text/x-gnumakefile:gnumakefile +50:application/x-hlmdl-sequence:**[0123456789][0123456789].sequence +50:text/x-makefile:gnumakefile 50:application/java-multimedia-file:*.jmf +50:text/x-othermakefile:makefile +50:application/x-qvm:*.qvm3 diff --git a/test/discard/mime.cache b/test/discard/mime.cache index da214b6761b9c67a2808c2ed061425501147fed5..ecf4deaecc4c541ca1ce3960b3386e2ccdc816a3 100644 GIT binary patch literal 776 zcmZ`$Jx&5a82xtD#KHr31Vda<1FryIN6u?zW;A#$sw1>IRVaq7`P>J*MSY-6?g;Qflm>~p=ydm z^`p|%8%#72C32d;(4r^XDwL$O=tww5eJw}vP$iNmU)N6pIgCYbUTYll2I!g3H>nH0 zAk?kU8_B^~Momn})p%3S#3|deP`KFIE?25MyL_RlgJ|A;2m&%L@kuzh*!b#(p<32CM*i7SG|B{XS^`nMgZ_w%SIq#7k O&gb2^*J|qgkADEK1b+tr literal 504 zcmZWlu}%U(5S>-*{Qy3|!jr^`mSAIOE}^BF=mHD3cN$I%seXT}el z_*E92xA%^dvCAyp(j;Gbp4(sB>@SnRbJU|PW2a1-ZB;I0>~bRKd1BG9EWBNYg^QT_ zcTN$fc2NzJg*Xfh;G4#es;TC$)$gEVjrUMr#ij+FX?za7(zp#3;6ISe5S)T%SlNY2 zZVO_+nW`VDU#s7!e}W3+Rv~tpS4kY9u49jp?>RZ-(`)bs6{m F#{oc3N$LOq diff --git a/test/discard/packages/discard.xml b/test/discard/packages/discard.xml index 9060f76..95e28f1 100644 --- a/test/discard/packages/discard.xml +++ b/test/discard/packages/discard.xml @@ -10,7 +10,12 @@ Java multimedia file - + + Makefile + + + + Makefile @@ -27,4 +32,13 @@ + + Half-Life model sequence + + + + + Quake III virtual machine bytecode + + diff --git a/test/discard/subclasses b/test/discard/subclasses index 2507197..ed88348 100644 --- a/test/discard/subclasses +++ b/test/discard/subclasses @@ -1 +1,2 @@ -text/x-gnumakefile text/plain +text/x-othermakefile text/plain +text/x-makefile text/plain diff --git a/test/discard/types b/test/discard/types index 240ca92..52d4e05 100644 --- a/test/discard/types +++ b/test/discard/types @@ -1,5 +1,8 @@ application/java-multimedia-file +application/x-hlmdl-sequence application/x-otherpak application/x-pak +application/x-qvm image/x-somesprite -text/x-gnumakefile +text/x-makefile +text/x-othermakefile diff --git a/test/discard/version b/test/discard/version index 7e32cd5..810ee4e 100644 --- a/test/discard/version +++ b/test/discard/version @@ -1 +1 @@ -1.3 +1.6 diff --git a/test/mime/globs b/test/mime/globs index 0bcf671..8fcb1c2 100644 --- a/test/mime/globs +++ b/test/mime/globs @@ -1,16 +1,19 @@ # This file was automatically generated by the # update-mime-database command. DO NOT EDIT! +text/x-makefile:__NOGLOBS__ +application/x-hlmdl-sequence:__NOGLOBS__ +application/x-qvm:__NOGLOBS__ image/x-sprite32:*.spr32 -application/x-pak:pak*.pak application/x-iqm:*.iqm text/x-q3shader:*.shader -application/x-general-long-glob:general*_long_glob image/x-sprite32:*.sp2 image/x-q2sprite:*.sp2 +application/x-general-long-glob:general*_long_glob image/x-qsprite:*.spr image/x-sprite32:*.spr image/x-hlsprite:*.spr text/x-ent:*.ent +application/x-pak:pak*.pak application/x-wad:*.wad application/x-wad2:*.wad application/x-wad3:*.wad @@ -28,15 +31,14 @@ application/x-mdl:*.mdl application/x-rmf:*.rmf application/x-md2:*.md2 application/x-md3:*.md3 -application/x-md4:*.md4 application/x-lmp:*.lmp +application/x-md4:*.md4 application/x-qvm:*.qvm text/x-liblist:liblist.gam application/x-jmf:*.jmf -image/x-vtf:*.vtf application/x-gcf:*.gcf +image/x-vtf:*.vtf text/x-qcsrc:*.qc -text/x-makefile:gnumakefile text/x-qchdr:*.qh application/x-general-glob:general*glob application/x-vmf:*.vmf diff --git a/test/mime/globs2 b/test/mime/globs2 index f561db6..3982eb7 100644 --- a/test/mime/globs2 +++ b/test/mime/globs2 @@ -1,18 +1,21 @@ # This file was automatically generated by the # update-mime-database command. DO NOT EDIT! +0:text/x-makefile:__NOGLOBS__ +0:application/x-hlmdl-sequence:__NOGLOBS__ +0:application/x-qvm:__NOGLOBS__ 50:image/x-sprite32:*.spr32 -50:application/x-pak:pak*.pak:cs -50:application/x-pak:pak*.pak 50:application/x-iqm:*.iqm 50:text/x-q3shader:*.shader:cs 50:text/x-q3shader:*.shader -50:application/x-general-long-glob:general*_long_glob 50:image/x-sprite32:*.sp2 50:image/x-q2sprite:*.sp2 +50:application/x-general-long-glob:general*_long_glob 50:image/x-qsprite:*.spr 50:image/x-sprite32:*.spr 50:image/x-hlsprite:*.spr 50:text/x-ent:*.ent +50:application/x-pak:pak*.pak:cs +50:application/x-pak:pak*.pak 50:application/x-wad:*.wad 50:application/x-wad2:*.wad 50:application/x-wad3:*.wad @@ -30,15 +33,14 @@ 50:application/x-rmf:*.rmf 50:application/x-md2:*.md2 50:application/x-md3:*.md3 -50:application/x-md4:*.md4 50:application/x-lmp:*.lmp +50:application/x-md4:*.md4 50:application/x-qvm:*.qvm 50:text/x-liblist:liblist.gam 50:application/x-jmf:*.jmf -50:image/x-vtf:*.vtf 50:application/x-gcf:*.gcf +50:image/x-vtf:*.vtf 50:text/x-qcsrc:*.qc -50:text/x-makefile:gnumakefile 50:text/x-qchdr:*.qh 50:application/x-general-glob:general*glob 50:application/x-vmf:*.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xTk%ovD0T zo5GXAKI(Pqw-v9?=h&|BltVw9QhXA9z;FBTC@2SX(Hw%zizJX%DT( z`onic3EAOIV955@r~aPpZ0YZdp8mVQwm;9-9_IQRqJ%6v3T*p7u${qc|HH`d;qT}X zYxr>w{gWPg-VJ-`^%?)EtpsoCw|eNed+48u9x;#Pfw5*s{O3LVUx=RfXYBxg-feT( z@pnw6V7lwrvHE_Av-n-Z2R+Vu!rfNwUyva{csQci5~ioEj{{ZKR$eqk63!L=K3=| z^k;kMXM5=Lrhakp@|8>HzMTJJanboLJfFY1a2ige`~?sCbwn>O%zg9qx97f^yL2T# zchULRg-ho-=ktY0%qh%i%q#Q%yju7R{XqExU;^{k=b71WE}eJg|9viBz{I~vO!!KKj$Q-yzN?;7=9Makefile - + digital photos diff --git a/test/mime/packages/quake-hl.xml b/test/mime/packages/quake-hl.xml index 046a90a..b68d7e9 100644 --- a/test/mime/packages/quake-hl.xml +++ b/test/mime/packages/quake-hl.xml @@ -207,6 +207,7 @@ + @@ -315,6 +316,7 @@ + diff --git a/test/mime/version b/test/mime/version index 7e32cd5..810ee4e 100644 --- a/test/mime/version +++ b/test/mime/version @@ -1 +1 @@ -1.3 +1.6 diff --git a/test/note.txt b/test/note.txt new file mode 100644 index 0000000..b4a35cb --- /dev/null +++ b/test/note.txt @@ -0,0 +1,3 @@ +update-mime-database from shared-mime-info 1.6 has bugs with writing the number of literal and glob patterns. +These tests use patched version to make 100% coverage of mime/detectors/cache.d possible. +Patch is provided as update-mime-database.c.patch file. diff --git a/test/update-mime-database.c.patch b/test/update-mime-database.c.patch new file mode 100644 index 0000000..879c786 --- /dev/null +++ b/test/update-mime-database.c.patch @@ -0,0 +1,42 @@ +2372a2373,2396 +> typedef struct +> { +> GetValueFunc *get_value; +> gpointer data; +> guint count; +> +> } CountData; +> +> static void +> count_map_entry (gpointer key, +> gpointer data) +> { +> CountData *count_data = (CountData *)data; +> gchar **values; +> +> values = (* count_data->get_value) (count_data->data, key); +> count_data->count += g_strv_length (values) / 3; +> g_strfreev (values); +> } +> +> static gchar ** +> get_glob_list_value (gpointer data, +> gchar *key); +> +2384a2409,2410 +> CountData count_data; +> guint count; +2394c2420,2430 +< if (!write_card32 (cache, keys->len)) +--- +> if (get_value == &get_glob_list_value) { +> count_data.count = 0; +> count_data.data = map; +> count_data.get_value = get_value; +> g_ptr_array_foreach (keys, count_map_entry, &count_data); +> count = count_data.count; +> } else { +> count = keys->len; +> } +> +> if (!write_card32 (cache, count)) diff --git a/test/update.sh b/test/update.sh index f302d41..98cd04d 100755 --- a/test/update.sh +++ b/test/update.sh @@ -1,5 +1,5 @@ DIRNAME=$(dirname -- $(readlink -f -- $0)) export XDG_DATA_HOME=$DIRNAME -update-mime-database $DIRNAME/mime -update-mime-database $DIRNAME/discard +$DIRNAME/update-mime-database $DIRNAME/mime +$DIRNAME/update-mime-database $DIRNAME/discard