summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2020-10-04 14:50:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2020-10-04 14:50:32 +0000
commitede3da3368e77e464dda151b9d3f7807aacf07eb (patch)
tree113ea3ed873fdedfbdd29bfeed975b5813bbd172 /tests
parentAdding upstream version 1.4.29. (diff)
downloadidentify-ede3da3368e77e464dda151b9d3f7807aacf07eb.tar.xz
identify-ede3da3368e77e464dda151b9d3f7807aacf07eb.zip
Adding upstream version 1.5.5.upstream/1.5.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/identify_test.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/identify_test.py b/tests/identify_test.py
index 44406a1..a80c401 100644
--- a/tests/identify_test.py
+++ b/tests/identify_test.py
@@ -217,6 +217,66 @@ def test_file_is_text_does_not_exist(tmpdir):
(b"#!/path'with/quotes y", ("/path'with/quotes", 'y')),
# Don't regress on leading/trailing ws
(b"#! /path'with/quotes y ", ("/path'with/quotes", 'y')),
+ # Test nix-shell specialites with shebang on second line
+ (
+ b'#! /usr/bin/env nix-shell\n'
+ b'#! nix-shell -i bash -p python',
+ ('bash',),
+ ),
+ (
+ b'#! /usr/bin/env nix-shell\n'
+ b'#! nix-shell -i python -p coreutils',
+ ('python',),
+ ),
+ (
+ b'#! /usr/bin/env nix-shell\n'
+ b'#! nix-shell -p coreutils -i python',
+ ('python',),
+ ),
+ # multi-line and no whitespace variation
+ (
+ b'#! /usr/bin/env nix-shell\n'
+ b'#! nix-shell -p coreutils\n'
+ b'#! nix-shell -i python',
+ ('python',),
+ ),
+ (
+ b'#! /usr/bin/env nix-shell\n'
+ b'#!nix-shell -p coreutils\n'
+ b'#!nix-shell -i python',
+ ('python',),
+ ),
+ (
+ b'#! /usr/bin/env nix-shell\n'
+ b'#!\xf9\x93\x01\x42\xcd',
+ ('nix-shell',),
+ ),
+ (
+ b'#! /usr/bin/env nix-shell\n'
+ b'#!\x00\x00\x00\x00',
+ ('nix-shell',),
+ ),
+ # non-proper nix-shell
+ (b'#! /usr/bin/nix-shell', ('/usr/bin/nix-shell',)),
+ (b'#! /usr/bin/env nix-shell', ('nix-shell',)),
+ (
+ b'#! /usr/bin/env nix-shell non-portable-argument',
+ ('nix-shell', 'non-portable-argument'),
+ ),
+ (
+ b'#! /usr/bin/env nix-shell\n'
+ b'#! nix-shell -i',
+ ('nix-shell',), # guard against index error
+ ),
+ # interpret quotes correctly
+ (
+ b'#!/usr/bin/env nix-shell\n'
+ b'#!nix-shell --argstr x "a -i python3 p"\n'
+ b'#!nix-shell -p hello\n'
+ b'#!nix-shell -i bash\n'
+ b'#!nix-shell --argstr y "b -i runhaskell q"',
+ ('bash',),
+ ),
(b'\xf9\x93\x01\x42\xcd', ()),
(b'#!\xf9\x93\x01\x42\xcd', ()),
(b'#!\x00\x00\x00\x00', ()),