* 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>