sbang: vendor sbang
`sbang` now lives at https://github.com/spack/sbang, and it has its own test suite that's more extensive than what's in Spack. We'll leave sbang tests to sbang from now on, and just vendor `bin/sbang` directly. Remaining `sbang` tests have to do with patching files, not with `sbang`'s functionality. This update also fixes a bug with `sbang` and multiple command line arguments that was introduced in #19529. See: * https://github.com/spack/sbang/pull/1 * https://github.com/spack/sbang/pull/2 - [x] include latest `sbang` from https://github.com/spack/sbang - [x] remove old `sbang` tests from Spack - [x] update `COPYRIGHT` and `cmd/license.py`
This commit is contained in:
@@ -32,7 +32,6 @@
|
||||
# spack scripts
|
||||
r'^bin/spack$',
|
||||
r'^bin/spack-python$',
|
||||
r'^bin/sbang$',
|
||||
|
||||
# all of spack core
|
||||
r'^lib/spack/spack/.*\.py$',
|
||||
|
@@ -217,68 +217,3 @@ def test_install_sbang(install_mockery):
|
||||
# install again and make sure sbang is still fine
|
||||
sbang.install_sbang()
|
||||
check_sbang_installation()
|
||||
|
||||
|
||||
def test_sbang_fails_without_argument():
|
||||
sbang = which(spack.paths.sbang_script)
|
||||
sbang(fail_on_error=False)
|
||||
assert sbang.returncode == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize("shebang,returncode,expected", [
|
||||
# perl, with and without /usr/bin/env
|
||||
("#!/path/to/perl", 0, "/path/to/perl -x"),
|
||||
("#!/usr/bin/env perl", 0, "/usr/bin/env perl -x"),
|
||||
|
||||
# perl -w, with and without /usr/bin/env
|
||||
("#!/path/to/perl -w", 0, "/path/to/perl -w -x"),
|
||||
("#!/usr/bin/env perl -w", 0, "/usr/bin/env perl -w -x"),
|
||||
|
||||
# ruby, with and without /usr/bin/env
|
||||
("#!/path/to/ruby", 0, "/path/to/ruby -x"),
|
||||
("#!/usr/bin/env ruby", 0, "/usr/bin/env ruby -x"),
|
||||
|
||||
# python, with and without /usr/bin/env
|
||||
("#!/path/to/python", 0, "/path/to/python"),
|
||||
("#!/usr/bin/env python", 0, "/usr/bin/env python"),
|
||||
|
||||
# php with one-line php comment
|
||||
("<?php #!/usr/bin/php ?>", 0, "/usr/bin/php"),
|
||||
|
||||
# simple shell scripts
|
||||
("#!/bin/sh", 0, "/bin/sh"),
|
||||
("#!/bin/bash", 0, "/bin/bash"),
|
||||
|
||||
# error case: sbang as infinite loop
|
||||
("#!/path/to/sbang", 1, None),
|
||||
("#!/usr/bin/env sbang", 1, None),
|
||||
|
||||
# lua
|
||||
("--!/path/to/lua", 0, "/path/to/lua"),
|
||||
|
||||
# node
|
||||
("//!/path/to/node", 0, "/path/to/node"),
|
||||
])
|
||||
def test_sbang_with_specific_shebang(
|
||||
tmpdir, shebang, returncode, expected):
|
||||
|
||||
script = str(tmpdir.join("script"))
|
||||
|
||||
# write a script out with <shebang> on second line
|
||||
with open(script, "w") as f:
|
||||
f.write("#!/bin/sh {sbang}\n{shebang}\n".format(
|
||||
sbang=spack.paths.sbang_script,
|
||||
shebang=shebang
|
||||
))
|
||||
fs.set_executable(script)
|
||||
|
||||
# test running the script in debug, which prints what would be executed
|
||||
exe = which(script)
|
||||
out = exe(output=str, fail_on_error=False, env={"SBANG_DEBUG": "1"})
|
||||
|
||||
# check error status and output vs. expected
|
||||
assert exe.returncode == returncode
|
||||
|
||||
if expected is not None:
|
||||
expected += " " + script
|
||||
assert expected == out.strip()
|
||||
|
Reference in New Issue
Block a user