@ 201216.1

140625.5 · 0eef7cbee8286807a0ce1ada1029c21b1ef0c0c8

Add test cases for a big file.

reading declarations

.gitignore

@@ -23,4 +23,6 @@ missing src/config.h* stamp-h1 tests/*.err+tests/big/*.err+tests/big/big_file.txt the_silver_searcher.spec\ No newline at end of file

Makefile.am

@@ -17,4 +17,7 @@ EXTRA_DIST = Makefile.w32 LICENSE NOTICE the_silver_searcher.spec README.md test: 	cram -v tests/*.t +test_big:+	cram -v tests/big/*.t+ .PHONY : all test clean

tests/big/big_file.t

new file mode 100644@@ -0,0 +1,20 @@+Setup and create really big file:++  $ . $TESTDIR/../setup.sh+  $ python $TESTDIR/create_big_file.py $TESTDIR/big_file.txt++Search a big file:++  $ $TESTDIR/../../ag --nocolor --workers=1 --parallel hello $TESTDIR/big_file.txt+  33554432:hello1073741824+  67108864:hello2147483648+  100663296:hello3221225472+  134217728:hello4294967296+  167772160:hello5368709120+  201326592:hello6442450944+  234881024:hello7516192768+  268435456:hello++Fail to regex search a big file:+  $ $TESTDIR/../../ag --nocolor --workers=1 --parallel 'hello.*' $TESTDIR/big_file.txt+  ERR: Skipping /Users/ggreer/code/ag/tests/big/big_file.txt: pcre_exec() can't handle files larger than 2147483647 bytes.

tests/big/create_big_file.py

new file mode 100755@@ -0,0 +1,29 @@+#!/usr/bin/env python++# Create an 8GB file of mostly "abcdefghijklmnopqrstuvwxyz01234",+# with a few instances of "hello"++import sys++if len(sys.argv) != 2:+    print("Usage: %s big_file.txt" % sys.argv[0])+    sys.exit(1)++big_file = sys.argv[1]+++def create_big_file():+    with open(big_file, "w") as fd:+        for i in range(1, 2**28):+            byte = i * 32+            if byte % 2**30 == 0:+                fd.write("hello%s\n" % byte)+            else:+                fd.write("abcdefghijklmnopqrstuvwxyz01234\n")+        fd.write("hello\n")+++try:+    fd = open(big_file, "r")+except Exception as e:+    create_big_file()