Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
matrix:
os:
- 'ubuntu-18.04'
# - 'windows-2019'
- 'windows-2019'
- 'macos-10.15'
python:
- '3.6'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
matrix:
os:
- 'ubuntu-18.04'
# - 'windows-2019'
- 'windows-2019'
- 'macos-10.15'
python:
- '3.6'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
matrix:
os:
- 'ubuntu-18.04'
# - 'windows-2019' # need to be fixed, see: https://github.com/opendilab/treevalue/issues/41
- 'windows-2019' # need to be fixed, see: https://github.com/opendilab/treevalue/issues/41
- 'macos-10.15'
python-version:
- '3.6'
Expand All @@ -29,21 +29,21 @@ jobs:

steps:
- name: Get system version for Linux
if: ${{ contains(matrix.os, 'ubuntu') }}
if: ${{ runner.os == 'Linux' }}
shell: bash
run: |
echo "OS_NAME=Linux" >> $GITHUB_ENV
echo "IS_WIN=" >> $GITHUB_ENV
echo "IS_MAC=" >> $GITHUB_ENV
- name: Get system version for Windows
if: ${{ contains(matrix.os, 'windows') }}
if: ${{ runner.os == 'Windows' }}
shell: bash
run: |
echo "OS_NAME=Windows" >> $GITHUB_ENV
echo "IS_WIN=1" >> $GITHUB_ENV
echo "IS_MAC=" >> $GITHUB_ENV
- name: Get system version for MacOS
if: ${{ contains(matrix.os, 'macos') }}
if: ${{ runner.os == 'macOS' }}
shell: bash
run: |
echo "OS_NAME=MacOS" >> $GITHUB_ENV
Expand Down
14 changes: 13 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,23 @@ requires = [
[tool.cibuildwheel]
skip = ["pp*"] # Do not build for PyPy

## Windows build configuration
[tool.cibuildwheel.windows]
archs = ["x86", 'AMD64']
before-test = [# Unittest for windows
"pip install -r \"{project}\\requirements-test-win.txt\"",
]
test-command = [
"xcopy /e /i \"{project}\\test\" test",
"copy \"{project}\\pytest.ini\" pytest.ini",
"pytest test -sv -m unittest --log-level=DEBUG",
"rmdir /s /q test",
]

## macOS build configuration
[tool.cibuildwheel.macos]
archs = ["x86_64", "arm64"] # Build for x86_64 and arm64
before-test = [# Unittest for linux
before-test = [# Unittest for macos
"pip install -r {project}/requirements-test.txt",
]
test-command = [
Expand Down
15 changes: 15 additions & 0 deletions requirements-test-win.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
coverage>=5
mock>=4.0.3
flake8~=3.5
pytest~=6.2.5
pytest-cov~=3.0.0
pytest-mock~=3.6.1
pytest-xdist>=1.34.0
pytest-rerunfailures~=10.2
pytest-timeout~=2.0.2
pytest-benchmark~=3.4.0
testtools>=2
hbutils>=0.6.13
setuptools<=59.5.0
numpy>=1.10
easydict>=1.7,<2
33 changes: 22 additions & 11 deletions test/entry/cli/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def test_simple_export(self):
with runner.isolated_filesystem():
result = runner.invoke(treevalue_cli, ['export', '-t', 'test.entry.cli.test_export.t1'])

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('t1.btv')
assert os.path.getsize('t1.btv') < 240

Expand All @@ -42,7 +43,8 @@ def test_multiple_export(self):
with runner.isolated_filesystem():
result = runner.invoke(treevalue_cli, ['export', '-t', 'test.entry.cli.test_export.*'])

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('t1.btv')
assert os.path.getsize('t1.btv') < 240
assert os.path.exists('t2.btv')
Expand All @@ -60,7 +62,8 @@ def test_multiple_export(self):
with runner.isolated_filesystem():
result = runner.invoke(treevalue_cli, ['export', '-t', 'test.entry.cli.test_export.t[23]'])

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert not os.path.exists('t1.btv')
assert os.path.exists('t2.btv')
assert os.path.getsize('t2.btv') < 290
Expand All @@ -78,7 +81,8 @@ def test_multiple_export_without_compression(self):
with pytest.warns(None):
result = runner.invoke(treevalue_cli, ['export', '-t', 'test.entry.cli.test_export.*', '-r'])

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('t1.btv')
assert os.path.getsize('t1.btv') < 2170
assert os.path.exists('t2.btv')
Expand All @@ -98,7 +102,8 @@ def test_multiple_export_without_compression(self):
result = runner.invoke(treevalue_cli, ['export', '-t', 'test.entry.cli.test_export.*',
'-r', '-c', 'zlib'])

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('t1.btv')
assert os.path.getsize('t1.btv') < 2170
assert os.path.exists('t2.btv')
Expand All @@ -119,7 +124,8 @@ def test_multiple_export_with_compress_define(self):
result = runner.invoke(treevalue_cli, ['export', '-t', 'test.entry.cli.test_export.*',
'-c', 'gzip'])

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('t1.btv')
assert os.path.getsize('t1.btv') < 220
assert os.path.exists('t2.btv')
Expand All @@ -140,7 +146,8 @@ def test_multiple_export_with_compress_define(self):
'-c', 'test.entry.cli.test_export._my_compress:test.entry.cli.test_export._my_decompress'
])

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('t1.btv')
assert os.path.getsize('t1.btv') < 330
assert os.path.exists('t2.btv')
Expand All @@ -167,7 +174,8 @@ def test_with_od(self):
'-o', 'subpath/t3.btv',
])

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('subpath/t1.btv')
assert os.path.getsize('subpath/t1.btv') < 290
assert os.path.exists('subpath/t2.btv')
Expand All @@ -190,7 +198,8 @@ def test_with_od(self):
'-d', 'subpath',
])

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('subpath/t1.btv')
assert os.path.getsize('subpath/t1.btv') < 290
assert os.path.exists('subpath/t2.btv')
Expand All @@ -210,7 +219,8 @@ def test_with_od(self):
'-d', 'subpath',
])

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert not os.path.exists('subpath/t1.btv')
assert os.path.exists('subpath/t2.btv')
assert os.path.getsize('subpath/t2.btv') < 290
Expand All @@ -229,7 +239,8 @@ def test_with_od(self):
'-o', 'ppp.btv'
])

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert not os.path.exists('t1.btv')
assert not os.path.exists('t2.btv')
assert os.path.exists('ppp.btv')
Expand Down
50 changes: 34 additions & 16 deletions test/entry/cli/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest
from click.testing import CliRunner
from hbutils.testing import cmdv
from hbutils.testing import cmdv, OS

from treevalue import FastTreeValue, dump, graphics
from treevalue.entry.cli import treevalue_cli
Expand Down Expand Up @@ -36,7 +36,8 @@ def test_simple_code_graph(self):
'-o', 'test_graph.svg', '-o', 'test_graph.gv'],
)

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 7000
assert os.path.exists('test_graph.gv')
Expand All @@ -52,7 +53,8 @@ def test_simple_code_graph_to_stdout(self):
'-o', 'test_graph.svg', '-o', 'test_graph.gv', '-O'],
)

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert not os.path.exists('test_graph.svg')
assert not os.path.exists('test_graph.gv')
assert len(result.output) <= 2500
Expand All @@ -66,7 +68,8 @@ def test_simple_code_multiple_graph(self):
args=['graph', '-t', 'test.entry.cli.test_graph.t[12]', '-o', 'test_graph.svg'],
)

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 13000

Expand All @@ -76,7 +79,8 @@ def test_simple_code_multiple_graph(self):
args=['graph', '-t', 'test.entry.cli.test_graph.*', '-o', 'test_graph.svg'],
)

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 17500

Expand All @@ -92,7 +96,8 @@ def test_simple_binary_graph(self):
args=['graph', '-t', 'g1.bg', '-o', 'test_graph.svg'],
)

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 6500

Expand All @@ -109,7 +114,8 @@ def test_simple_binary_graph(self):
args=['graph', '-t', '*.bg', '-o', 'test_graph.svg'],
)

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 17500

Expand All @@ -122,7 +128,8 @@ def test_simple_binary_graph(self):
args=['graph', '-t', 'test.entry.cli.test_graph.t1', '-o', 'test_graph.svg'],
)

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 13000

Expand All @@ -135,7 +142,8 @@ def test_simple_binary_graph(self):
args=['graph', '-t', 'test.entry.cli.test_graph.t1', '-o', 'test_graph.svg'],
)

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 6500

Expand All @@ -149,7 +157,8 @@ def test_duplicates(self):
'-o', 'test_graph.svg'],
)

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 12000

Expand All @@ -162,7 +171,8 @@ def test_duplicates(self):
'-o', 'test_graph.svg'],
)

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
import shutil
shutil.copy('test_graph.svg', os.path.join(_p, 'test_graph.svg'))
Expand All @@ -179,7 +189,8 @@ def test_graph(self):
'-t', 'first title', '-o', 'test_graph.svg'],
)

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 16500

Expand All @@ -196,7 +207,8 @@ def test_cfg(self):
'-c', 'bgcolor=#ffffff00', '-O'],
)

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert len(result.output) <= 6000
assert '#ffffff00' in result.output

Expand All @@ -207,7 +219,9 @@ def test_cfg(self):
'-c', 'bgcolor#ffffff00', '-O'],
)

assert result.exit_code != 0
assert result.exit_code != 0, f'The running expected to raise RuntimeError ' \
f'but not actually (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert "Configuration should be KEY=VALUE, but 'bgcolor#ffffff00' found." in result.output

@unittest.skipUnless(cmdv('dot'), 'Dot installed only')
Expand All @@ -227,6 +241,10 @@ def test_file_with_invalid_permission(self):
args=['graph', '-t', 'g1.bg', '-o', 'test_graph.svg'],
)

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert os.path.exists('test_graph.svg')
assert os.path.getsize('test_graph.svg') <= 1000
if OS.windows:
assert os.path.getsize('test_graph.svg') <= 2000
else:
assert os.path.getsize('test_graph.svg') <= 1000
3 changes: 2 additions & 1 deletion test/entry/cli/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test_version(self):
runner = CliRunner()
result = runner.invoke(treevalue_cli, args=['-v'])

assert result.exit_code == 0
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
f'The output is:\n{result.output}'
assert __TITLE__.lower() in result.stdout.lower()
assert __VERSION__.lower() in result.stdout.lower()
Loading