vhdl-style-guide/tests/context
Brandon Maier 4b43d5744a
Fix for pytest on Windows (#1338)
* tests: support admin check on Windows

The tests fail on Windows with the following

> ___________ ERROR collecting tests/source_file/test_source_file.py ____________
> tests\source_file\test_source_file.py:24: in <module>
>     class testOSError(unittest.TestCase):
> tests\source_file\test_source_file.py:39: in testOSError
>     @unittest.skipIf("SUDO_UID" in os.environ.keys() or os.geteuid() == 0, "We are root. Root always has permissions so test will fail.")
> E   AttributeError: module 'os' has no attribute 'geteuid'

Catch the AttributeError and attempt to check for admin when on Windows

Signed-off-by: Brandon Maier <brandon.maier@gmail.com>

* tests: support running 'vsg' binary on Windows

A large number of tests fail on Windows with the following error

> ________ test_severity_using_main.test_architecture_with_configuration ________
> [gw0] win32 -- Python 3.8.20 %PREFIX%\python.exe
>
> self = <tests.severity.test_main.test_severity_using_main testMethod=test_architecture_with_configuration>
>
>     def test_architecture_with_configuration(self):
>         try:
> >           subprocess.check_output(["bin/vsg", "-f", self._sArchitectureFileName, "-c", sConfigFile])
>
> tests\severity\test_main.py:86:
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> ..\_test_env\lib\subprocess.py:415: in check_output
>     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
> ..\_test_env\lib\subprocess.py:493: in run
>     with Popen(*popenargs, **kwargs) as process:
> ..\_test_env\lib\subprocess.py:858: in __init__
>     self._execute_child(args, executable, preexec_fn, close_fds,
...
> E FileNotFoundError: [WinError 2] The system cannot find the file specified
> ..\_test_env\lib\subprocess.py:1327: FileNotFoundError

Tests that call "bin/vsg" are relying on the Unix shebang (e.g.
"#!/usr/bin/python") to launch `vsg` using the Python interpreter, But
this is not supported on Windows. Instead launch `vsg` with Python
directly.

Signed-off-by: Brandon Maier <brandon.maier@gmail.com>

* tests: normalize line endings for Windows tests

Many of the tests that compare `vsg` stdout fail with a warning as
follows.

> First differing element 0:
> 'ERRO[19 chars]1.vhd(7)port_007 -- Change number of spaces after *in* to 4.\r'
> 'ERRO[19 chars]1.vhd(7)port_007 -- Change number of spaces after *in* to 4.'

The tests use `.split('\n')` to split stdout and stderr by the Linux
line terminator '\n'. But on Windows this causes test failures as the
line terminator is '\r\n'.

Instead use Python `.splitlines()`. which will split on both Linux and
Windows style line terminators. `.splitlines()` also removes empty
trailing lines, so we must modify the expected output accordingly.

Signed-off-by: Brandon Maier <brandon.maier@gmail.com>

* Fixing test error by including encoding when reading vhdl files.

* Fixing second error due to glob function using incorrect divider.

* Fixed file compare not working in quality report test.

* Fixed output error message to be independent of platform.

* Skipping permission tests when running on windows.

* Skipping file permission test when running on Windows.

---------

Signed-off-by: Brandon Maier <brandon.maier@gmail.com>
Co-authored-by: Jeremiah Leary <jeremiah.c.leary@gmail.com>
2025-01-13 20:46:16 -06:00
..
__init__.py tests: move out of vsg 2024-03-23 18:48:35 +02:00
context_classification_test_input.fixed.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
context_classification_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_001_test_input.fixed.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_001_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_002_test_input.fixed.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_002_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_003_test_input.fixed.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_003_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_004_test_input.fixed_lower.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_004_test_input.fixed_upper.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_004_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_005_test_input.fixed.vhd style: apply codespell 2024-03-24 21:16:34 +02:00
rule_005_test_input.vhd style: apply codespell 2024-03-24 21:16:34 +02:00
rule_006_test_input.fixed.vhd style: apply codespell 2024-03-24 21:16:34 +02:00
rule_006_test_input.vhd style: apply codespell 2024-03-24 21:16:34 +02:00
rule_007_test_input.fixed.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_007_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_008_test_input.fixed.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_008_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_009_test_input.fixed.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_009_test_input.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_010_test_input.fixed.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_010_test_input.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_011_test_input.fixed.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_011_test_input.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_012_test_input.fixed_lower.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_012_test_input.fixed_upper.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_012_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_013_test_input.fixed_lower.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_013_test_input.fixed_upper.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_013_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_014_test_input.fixed_lower.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_014_test_input.fixed_upper.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_014_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_015_test_input.fixed_lower.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_015_test_input.fixed_upper.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_015_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_016_test_input.fixed_lower.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_016_test_input.fixed_upper.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_016_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_017_test_input.fixed.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_017_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_018_test_input.fixed.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_018_test_input.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_019_test_input.fixed.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_019_test_input.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_020_test_input.fixed.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_020_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_021_test_input.fixed_add.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_021_test_input.fixed_remove.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_021_test_input.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_022_test_input.fixed_add.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_022_test_input.fixed_remove.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_022_test_input.vhd style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
rule_023_test_input.fixed.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_023_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_024_test_input.fixed.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_024_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_025_test_input.fixed.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
rule_025_test_input.vhd tests: move out of vsg 2024-03-23 18:48:35 +02:00
test_main.py Fix for pytest on Windows (#1338) 2025-01-13 20:46:16 -06:00
test_rule_001.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_002.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_003.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_004.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_005.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_006.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_007.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_008.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_009.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_010.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_011.py style: apply end-of-file-fixer 2024-03-24 21:16:35 +02:00
test_rule_012.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_013.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_014.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_015.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_016.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_017.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_018.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_019.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_020.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_021.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_022.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_023.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_024.py style: apply black 2024-03-24 21:16:35 +02:00
test_rule_025.py style: apply black 2024-03-24 21:16:35 +02:00