summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2020-10-04 14:50:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2020-10-04 14:50:35 +0000
commitccc606e17ceea4cdc9666131506c19b74a528d1a (patch)
treea00063fa71c7561768e1bae568e323b3030b2839 /tests
parentReleasing debian version 1.4.29-1. (diff)
downloadidentify-ccc606e17ceea4cdc9666131506c19b74a528d1a.tar.xz
identify-ccc606e17ceea4cdc9666131506c19b74a528d1a.zip
Merging upstream version 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', ()),