summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-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', ()),