From efcd8394cc64fbd490899e8a2ff559301ecfa56f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20H=C3=A4rnqvist?= <ivaha717@student.liu.se> Date: Tue, 25 Feb 2020 16:35:57 +0100 Subject: [PATCH] fix test setup --- .gitignore | 4 +++- CMakeLists.txt | 11 +-------- README.md | 46 ++++++++++++++++++++++--------------- test/CMakeLists.txt | 9 -------- {tests => test}/__init__.py | 0 test/test_main.cpp | 5 ---- test/test_port.py | 9 ++++++++ tests/test_port.py | 10 -------- 8 files changed, 41 insertions(+), 53 deletions(-) delete mode 100644 test/CMakeLists.txt rename {tests => test}/__init__.py (100%) delete mode 100644 test/test_main.cpp create mode 100644 test/test_port.py delete mode 100644 tests/test_port.py diff --git a/.gitignore b/.gitignore index 36987299..0bdf5476 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,6 @@ $RECYCLE.BIN/ *.stackdump [Dd]esktop.ini *.egg-info -__pycache__/ \ No newline at end of file +__pycache__/ +env/ +venv/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index ab4d1bf5..bcd7af2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,13 +76,4 @@ add_custom_target( COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_LIST_DIR}/${LIBRARY_NAME}" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${LIBRARY_NAME}" COMMENT "Copying python files to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${LIBRARY_NAME}" DEPENDS "${TARGET_NAME}" remove_old_python_dir -) -add_custom_target( - copy_misc_files ALL - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_LIST_DIR}/README.md" "${CMAKE_CURRENT_LIST_DIR}/LICENSE" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" - COMMENT "Copying misc. files to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" - DEPENDS "${TARGET_NAME}" -) - -enable_testing() -add_subdirectory(test) \ No newline at end of file +) \ No newline at end of file diff --git a/README.md b/README.md index 4552c3b6..58025fbb 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,10 @@ # B-ASIC - Better ASIC Toolbox B-ASIC is an ASIC toolbox for Python 3 that simplifies circuit design and optimization. -## Prerequisites +## Development +How to build and debug the library during development. + +### Prerequisites The following packages are required in order to build the library: * cmake 3.8+ * gcc 7+/clang 7+/msvc 16+ @@ -16,9 +19,6 @@ The following packages are required in order to build the library: * numpy * pyside2/pyqt5 -## Development -How to build and debug the library during development. - ### Using CMake directly How to build using CMake. @@ -64,13 +64,34 @@ The output gets written to `B-ASIC/dist/b-asic-<version>.tar.gz`. #### Installation (Binary distribution) In `B-ASIC/dist`: ``` -python3 -m pip install b_asic-<version>-<python_tag>-<abi_tag>-<platform_tag>.whl +pip install b_asic-<version>-<python_tag>-<abi_tag>-<platform_tag>.whl ``` #### Installation (Source distribution) In `B-ASIC/dist`: ``` -python3 -m pip install b-asic-<version>.tar.gz +pip install b-asic-<version>.tar.gz +``` + +### Running tests +How to run the tests using pytest in a virtual environment. + +#### Linux/OS X +In `B-ASIC`: +``` +python3 -m venv env +source env/bin/activate +pip install . +pytest +``` + +#### Windows +In `B-ASIC` (as admin): +``` +python3 -m venv env +.\env\Scripts\activate.bat +pip install . +pytest ``` ## Usage @@ -78,7 +99,7 @@ How to build and use the library as a user. ### Installation ``` -python3 -m pip install b_asic +pip install b_asic ``` ### Importing @@ -88,17 +109,6 @@ python3 >>> help(asic) ``` -## Running tests -### pytest -Run all tests against installed version off b_asic using a virtual enviroment -In `B-ASIC`: -``` -python3 -m venv .venv -source .venv/bin/activate -pip install . -pytest -``` - ## License B-ASIC is distributed under the MIT license. See the included LICENSE file for more information. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index c9fd7f20..00000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.13) - -project("B-ASIC-test") - -add_executable( - test-main - "${CMAKE_CURRENT_SOURCE_DIR}/test_main.cpp" -) -add_test(NAME test-main COMMAND test-main) \ No newline at end of file diff --git a/tests/__init__.py b/test/__init__.py similarity index 100% rename from tests/__init__.py rename to test/__init__.py diff --git a/test/test_main.cpp b/test/test_main.cpp deleted file mode 100644 index 30ea92f7..00000000 --- a/test/test_main.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// TODO: Tests - -int main() { - return 0; -} \ No newline at end of file diff --git a/test/test_port.py b/test/test_port.py new file mode 100644 index 00000000..62e17ea5 --- /dev/null +++ b/test/test_port.py @@ -0,0 +1,9 @@ +import b_asic +import pytest + +@pytest.fixture +def outp_port(): + return b_asic.InputPort(0) + +def test_port(outp_port): + assert outp_port.signals() == [] \ No newline at end of file diff --git a/tests/test_port.py b/tests/test_port.py deleted file mode 100644 index 498233bb..00000000 --- a/tests/test_port.py +++ /dev/null @@ -1,10 +0,0 @@ -from b_asic import InputPort -import pytest - -@pytest.fixture -def outp_port(): - return InputPort(0) - - -def test_port(outp_port): - assert outp_port.signals() == [] -- GitLab