Skip to content

Commit

Permalink
Create compatibility module with tests
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Winkler <[email protected]>
  • Loading branch information
rw1nkler committed Sep 14, 2020
1 parent f619454 commit 039cee9
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ jobs:
script:
- cd tests && python3 -m unittest test.TestRTLIL

- stage: Tests
name: "Test compatibility package"
script:
- cd tests && python3 -m unittest test.TestCompat

- stage: Build
name: "Build"
script:
Expand Down
44 changes: 33 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,57 @@ version-clean:

clean: version-clean

# Build and upload commands
# Build and upload main package

#PYPI_TEST = --repository-url https://test.pypi.org/legacy/
PYPI_TEST = --repository testpypi

build: $(VERSION_PY) | $(CONDA_ENV_PYTHON)
$(IN_CONDA_ENV) python setup.py sdist bdist_wheel && twine check dist/*

.PHONY: build

build-clean:
rm -rf env/downloads/conda-pkgs
rm -rf build dist *.egg-info
find -name *.pyc -delete
find -name __pycache__ -delete

clean: build-clean

#PYPI_TEST = --repository-url https://test.pypi.org/legacy/
#PYPI_TEST = --repository testpypi

upload-test: build | $(CONDA_ENV_PYTHON)
$(IN_CONDA_ENV) twine upload ${PYPI_TEST} dist/*

.PHONY: upload-test

upload: build | $(CONDA_ENV_PYTHON)
$(IN_CONDA_ENV) twine upload --verbose dist/*

.PHONY: upload
.PHONY: build build-clean upload upload-test

# Build and upload compatibility package

COMPAT_PACKAGE_DIR = compat

build_compat: $(VERSION_PY) | $(CONDA_ENV_PYTHON)
$(IN_CONDA_ENV) cd $(COMPAT_PACKAGE_DIR); python setup.py sdist bdist_wheel && twine check dist/*

build_compat-clean:
cd $(COMPAT_PACKAGE_DIR); rm -rf env/downloads/conda-pkgs
cd $(COMPAT_PACKAGE_DIR); rm -rf build dist *.egg-info
cd $(COMPAT_PACKAGE_DIR); find -name *.pyc -delete
cd $(COMPAT_PACKAGE_DIR); find -name __pycache__ -delete

upload_compat-test: build_compat | $(CONDA_ENV_PYTHON)
$(IN_CONDA_ENV) cd $(COMPAT_PACKAGE_DIR); twine upload ${PYPI_TEST} dist/*

upload_compat: build_compat | $(CONDA_ENV_PYTHON)
$(IN_CONDA_ENV) cd $(COMPAT_PACKAGE_DIR); twine upload --verbose dist/*

.PHONY: build_compat build_compat-clean upload_compat-test upload_compat

# Tests

test: $(VERSION_PY) | $(CONDA_ENV_PYTHON)
$(IN_CONDA_ENV) cd docs; make html
$(IN_CONDA_ENV) cd tests; make test

.PHONY: test

# Cleanup

clean: build-clean build_compat-clean
63 changes: 63 additions & 0 deletions compat/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2020 The SymbiFlow Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

import sys
from os import path

from setuptools import setup, find_packages

__dir__ = path.dirname(path.abspath(__file__))
readme_file = path.join(__dir__, '../README.rst')
try:
with open(readme_file) as f:
readme = f.read()
except FileNotFoundError as e:
import traceback
traceback.print_exc()
readme = ''
__version__ = 'error'

install_requires = [
'sphinxcontrib-hdl-diagrams'
]

setup(
name='sphinxcontrib-verilog-diagrams',
version="0.1.0",
description='Generate diagrams from Verilog in Sphinx.',
long_description=readme,
long_description_content_type="text/x-rst",
author="The SymbiFlow Authors",
author_email='[email protected]',
url='https://github.com/SymbiFlow/sphinxcontrib-hdl-diagrams',
packages=find_packages(),
license="Apache 2.0",
keywords='Verilog sphinx sphinx-extension netlistsvg FPGA',
classifiers=[
'Development Status :: 4 - Beta',
'Framework :: Sphinx :: Extension',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Text Processing',
],
install_requires=install_requires,
)
11 changes: 11 additions & 0 deletions compat/sphinxcontrib_verilog_diagrams/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import sphinxcontrib_hdl_diagrams

def setup(app):
print("")
print("WARNING:")
print(" sphinxcontrib-verilog-diagram extension is depreciated!")
print(" Please use sphinxcontrib-hdl-diagrams instead:")
print(" https://github.com/SymbiFlow/sphinxcontrib-hdl-diagrams")
print("")

return sphinxcontrib_hdl_diagrams.setup(app)
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ dependencies:
- -r file:requirements.txt
- -r file:docs/requirements.txt
- .
- compat/.
31 changes: 31 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,36 @@ def test_yosys_script(self):
app = Sphinx(buildername="html", warningiserror=True, **sphinx_dirs)
app.build(force_all=True)


class TestCompat(TestBase):

TEST_CASE_NAME = "TestCompat"
TEST_CASE_BUILD_DIR = os.path.join("build", TEST_CASE_NAME)

def test_yosys_script(self):
TEST_NAME = "test_compat"
TEST_BUILD_DIR = os.path.join("build", self.TEST_CASE_NAME, TEST_NAME)
TEST_FILES = [
"test_compat/test_compat.rst",
"code/verilog/adder.v"
]
TEST_JINJA_DICT = {
"hdl_diagrams_path": "'{}'".format(HDL_DIAGRAMS_PATH),
"master_doc": "'test_compat'",
"custom_variables": """
extensions = [
'sphinxcontrib_verilog_diagrams',
]"""
}

self.prepare_test(TEST_NAME, TEST_BUILD_DIR, TEST_FILES, **TEST_JINJA_DICT)

# Run the Sphinx
sphinx_dirs = get_sphinx_dirs(TEST_BUILD_DIR)
with docutils_namespace():
app = Sphinx(buildername="html", warningiserror=True, **sphinx_dirs)
app.build(force_all=True)


if __name__ == '__main__':
unittest.main()
50 changes: 50 additions & 0 deletions tests/test_compat/test_compat.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Test Compatibility Package
==========================

This test checks whether the ``sphinxcontrib-verilog-diagrams`` compatibility
package works as intended.

Here is the fragment of the ``conf.py`` script, used to configure the extension::

extensions = [
'sphinxcontrib_verilog_diagrams',
]

Yosys BlackBox Diagram
----------------------

.. code-block:: rst
.. verilog-diagram:: adder.v
:type: yosys-blackbox
:module: ADDER
.. verilog-diagram:: adder.v
:type: yosys-blackbox
:module: ADDER

Yosys AIG Diagram
-----------------

.. code-block:: rst
.. verilog-diagram:: adder.v
:type: yosys-aig
:module: ADDER
.. verilog-diagram:: adder.v
:type: yosys-aig
:module: ADDER

Netlistsvg Diagram
------------------

.. code-block:: rst
.. verilog-diagram:: adder.v
:type: netlistsvg
:module: ADDER
.. verilog-diagram:: adder.v
:type: netlistsvg
:module: ADDER

0 comments on commit 039cee9

Please sign in to comment.