Skip to content

Commit 2a07cfb

Browse files
committed
Merge branch 'main' into doc/readme
2 parents 3806dc1 + ae999e1 commit 2a07cfb

12 files changed

+143
-59
lines changed

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
matrix:
5959
os:
6060
- 'ubuntu-18.04'
61-
# - 'windows-2019'
61+
- 'windows-2019'
6262
- 'macos-10.15'
6363
python:
6464
- '3.6'

.github/workflows/release_test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
matrix:
5050
os:
5151
- 'ubuntu-18.04'
52-
# - 'windows-2019'
52+
- 'windows-2019'
5353
- 'macos-10.15'
5454
python:
5555
- '3.6'

.github/workflows/test.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
matrix:
1919
os:
2020
- 'ubuntu-18.04'
21-
# - 'windows-2019' # need to be fixed, see: https://github.com/opendilab/treevalue/issues/41
21+
- 'windows-2019' # need to be fixed, see: https://github.com/opendilab/treevalue/issues/41
2222
- 'macos-10.15'
2323
python-version:
2424
- '3.6'
@@ -29,21 +29,21 @@ jobs:
2929

3030
steps:
3131
- name: Get system version for Linux
32-
if: ${{ contains(matrix.os, 'ubuntu') }}
32+
if: ${{ runner.os == 'Linux' }}
3333
shell: bash
3434
run: |
3535
echo "OS_NAME=Linux" >> $GITHUB_ENV
3636
echo "IS_WIN=" >> $GITHUB_ENV
3737
echo "IS_MAC=" >> $GITHUB_ENV
3838
- name: Get system version for Windows
39-
if: ${{ contains(matrix.os, 'windows') }}
39+
if: ${{ runner.os == 'Windows' }}
4040
shell: bash
4141
run: |
4242
echo "OS_NAME=Windows" >> $GITHUB_ENV
4343
echo "IS_WIN=1" >> $GITHUB_ENV
4444
echo "IS_MAC=" >> $GITHUB_ENV
4545
- name: Get system version for MacOS
46-
if: ${{ contains(matrix.os, 'macos') }}
46+
if: ${{ runner.os == 'macOS' }}
4747
shell: bash
4848
run: |
4949
echo "OS_NAME=MacOS" >> $GITHUB_ENV

pyproject.toml

+13-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,23 @@ requires = [
88
[tool.cibuildwheel]
99
skip = ["pp*"] # Do not build for PyPy
1010

11+
## Windows build configuration
12+
[tool.cibuildwheel.windows]
13+
archs = ["x86", 'AMD64']
14+
before-test = [# Unittest for windows
15+
"pip install -r \"{project}\\requirements-test-win.txt\"",
16+
]
17+
test-command = [
18+
"xcopy /e /i \"{project}\\test\" test",
19+
"copy \"{project}\\pytest.ini\" pytest.ini",
20+
"pytest test -sv -m unittest --log-level=DEBUG",
21+
"rmdir /s /q test",
22+
]
1123

1224
## macOS build configuration
1325
[tool.cibuildwheel.macos]
1426
archs = ["x86_64", "arm64"] # Build for x86_64 and arm64
15-
before-test = [# Unittest for linux
27+
before-test = [# Unittest for macos
1628
"pip install -r {project}/requirements-test.txt",
1729
]
1830
test-command = [

requirements-test-win.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
coverage>=5
2+
mock>=4.0.3
3+
flake8~=3.5
4+
pytest~=6.2.5
5+
pytest-cov~=3.0.0
6+
pytest-mock~=3.6.1
7+
pytest-xdist>=1.34.0
8+
pytest-rerunfailures~=10.2
9+
pytest-timeout~=2.0.2
10+
pytest-benchmark~=3.4.0
11+
testtools>=2
12+
hbutils>=0.6.13
13+
setuptools<=59.5.0
14+
numpy>=1.10
15+
easydict>=1.7,<2

test/entry/cli/test_export.py

+22-11
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def test_simple_export(self):
3030
with runner.isolated_filesystem():
3131
result = runner.invoke(treevalue_cli, ['export', '-t', 'test.entry.cli.test_export.t1'])
3232

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

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

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

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

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

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

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

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

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

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

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

232-
assert result.exit_code == 0
242+
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
243+
f'The output is:\n{result.output}'
233244
assert not os.path.exists('t1.btv')
234245
assert not os.path.exists('t2.btv')
235246
assert os.path.exists('ppp.btv')

test/entry/cli/test_graph.py

+34-16
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import pytest
99
from click.testing import CliRunner
10-
from hbutils.testing import cmdv
10+
from hbutils.testing import cmdv, OS
1111

1212
from treevalue import FastTreeValue, dump, graphics
1313
from treevalue.entry.cli import treevalue_cli
@@ -36,7 +36,8 @@ def test_simple_code_graph(self):
3636
'-o', 'test_graph.svg', '-o', 'test_graph.gv'],
3737
)
3838

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

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

69-
assert result.exit_code == 0
71+
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
72+
f'The output is:\n{result.output}'
7073
assert os.path.exists('test_graph.svg')
7174
assert os.path.getsize('test_graph.svg') <= 13000
7275

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

79-
assert result.exit_code == 0
82+
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
83+
f'The output is:\n{result.output}'
8084
assert os.path.exists('test_graph.svg')
8185
assert os.path.getsize('test_graph.svg') <= 17500
8286

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

95-
assert result.exit_code == 0
99+
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
100+
f'The output is:\n{result.output}'
96101
assert os.path.exists('test_graph.svg')
97102
assert os.path.getsize('test_graph.svg') <= 6500
98103

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

112-
assert result.exit_code == 0
117+
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
118+
f'The output is:\n{result.output}'
113119
assert os.path.exists('test_graph.svg')
114120
assert os.path.getsize('test_graph.svg') <= 17500
115121

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

125-
assert result.exit_code == 0
131+
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
132+
f'The output is:\n{result.output}'
126133
assert os.path.exists('test_graph.svg')
127134
assert os.path.getsize('test_graph.svg') <= 13000
128135

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

138-
assert result.exit_code == 0
145+
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
146+
f'The output is:\n{result.output}'
139147
assert os.path.exists('test_graph.svg')
140148
assert os.path.getsize('test_graph.svg') <= 6500
141149

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

152-
assert result.exit_code == 0
160+
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
161+
f'The output is:\n{result.output}'
153162
assert os.path.exists('test_graph.svg')
154163
assert os.path.getsize('test_graph.svg') <= 12000
155164

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

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

182-
assert result.exit_code == 0
192+
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
193+
f'The output is:\n{result.output}'
183194
assert os.path.exists('test_graph.svg')
184195
assert os.path.getsize('test_graph.svg') <= 16500
185196

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

199-
assert result.exit_code == 0
210+
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
211+
f'The output is:\n{result.output}'
200212
assert len(result.output) <= 6000
201213
assert '#ffffff00' in result.output
202214

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

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

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

230-
assert result.exit_code == 0
244+
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
245+
f'The output is:\n{result.output}'
231246
assert os.path.exists('test_graph.svg')
232-
assert os.path.getsize('test_graph.svg') <= 1000
247+
if OS.windows:
248+
assert os.path.getsize('test_graph.svg') <= 2000
249+
else:
250+
assert os.path.getsize('test_graph.svg') <= 1000

test/entry/cli/test_version.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def test_version(self):
1111
runner = CliRunner()
1212
result = runner.invoke(treevalue_cli, args=['-v'])
1313

14-
assert result.exit_code == 0
14+
assert result.exit_code == 0, f'Runtime Error (exitcode {result.exit_code}), ' \
15+
f'The output is:\n{result.output}'
1516
assert __TITLE__.lower() in result.stdout.lower()
1617
assert __VERSION__.lower() in result.stdout.lower()

0 commit comments

Comments
 (0)