From ffc6fbbde3eeca29d1eb3470610eb7ae5b9025f1 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 29 Feb 2016 19:35:13 -0800 Subject: Fix file for Java class files, improve script detection, and add tests. --- tests/file.test | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/file.test (limited to 'tests') diff --git a/tests/file.test b/tests/file.test new file mode 100644 index 00000000..86ddd9e1 --- /dev/null +++ b/tests/file.test @@ -0,0 +1,21 @@ +#!/bin/bash + +[ -f testing.sh ] && . testing.sh + +#testing "name" "command" "result" "infile" "stdin" + +touch empty +echo "#!/bin/bash" > bash.script +echo "#! /bin/bash" > bash.script2 +echo "#! /usr/bin/env python" > env.python.script +echo "Hello, world!" > ascii +echo "cafebabe000000310000" | xxd -r -p > java.class + +testing "file empty" "file empty" "empty: empty\n" "" "" +testing "file bash.script" "file bash.script" "bash.script: /bin/bash script\n" "" "" +testing "file bash.script with spaces" "file bash.script2" "bash.script2: /bin/bash script\n" "" "" +testing "file env python script" "file env.python.script" "env.python.script: python script\n" "" "" +testing "file ascii" "file ascii" "ascii: ASCII text\n" "" "" +testing "file java class" "file java.class" "java.class: Java class file, version 49.0\n" "" "" + +rm empty bash.script bash.script2 env.python.script ascii java.class -- cgit v1.2.3