diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2020-10-28 14:07:05 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2020-10-28 17:43:23 -0700 |
commit | aebf20ebdc0f5d1ea03956681e0b16ffaffa9568 (patch) | |
tree | 154464aab993ed2aa40d8b675516f707113a6338 /lib | |
parent | 44bacefb27675aaed22d77c768fb18a627e678eb (diff) | |
download | spack-aebf20ebdc0f5d1ea03956681e0b16ffaffa9568.tar.gz spack-aebf20ebdc0f5d1ea03956681e0b16ffaffa9568.tar.bz2 spack-aebf20ebdc0f5d1ea03956681e0b16ffaffa9568.tar.xz spack-aebf20ebdc0f5d1ea03956681e0b16ffaffa9568.zip |
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`
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/cmd/license.py | 1 | ||||
-rw-r--r-- | lib/spack/spack/test/sbang.py | 65 |
2 files changed, 0 insertions, 66 deletions
diff --git a/lib/spack/spack/cmd/license.py b/lib/spack/spack/cmd/license.py index 5fd57c39c9..84a4a02282 100644 --- a/lib/spack/spack/cmd/license.py +++ b/lib/spack/spack/cmd/license.py @@ -32,7 +32,6 @@ licensed_files = [ # spack scripts r'^bin/spack$', r'^bin/spack-python$', - r'^bin/sbang$', # all of spack core r'^lib/spack/spack/.*\.py$', diff --git a/lib/spack/spack/test/sbang.py b/lib/spack/spack/test/sbang.py index bdab7a8cfc..18bbe9f345 100644 --- a/lib/spack/spack/test/sbang.py +++ b/lib/spack/spack/test/sbang.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() |