Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: cms-dev/tests/test_cms_cmp.py

Issue 29588962: Issue 5934 - CMS testing automation (Closed)
Left Patch Set: Change the usage a bit, add some useful options, add a couple of tests Created Oct. 27, 2017, 5:38 p.m.
Right Patch Set: Improve documentation and structure following Tristan's comments Created Nov. 28, 2017, 4:11 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « cms-dev/cms_cmp.py ('k') | cms-dev/tox.ini » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # This file is part of Adblock Plus <https://adblockplus.org/>, 1 # This file is part of Adblock Plus <https://adblockplus.org/>,
2 # Copyright (C) 2017-present eyeo GmbH 2 # Copyright (C) 2017-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 # 12 #
13 # You should have received a copy of the GNU General Public License 13 # You should have received a copy of the GNU General Public License
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
15 15
16 import glob 16 import glob
17 import os 17 import os
18 import subprocess 18 import subprocess
19 import sys 19 import sys
20 20
21 import pytest 21 import pytest
22 22
23 CMSCMP = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'cms_cmp.py') 23 CMSCMP = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'cms_cmp.py')
24 24
25 25
26 def run_cms_cmp(*args, **kw): 26 def run_cms_cmp(*args, **kw):
27 return subprocess.check_call([sys.executable, CMSCMP] + list(args), **kw) 27 return subprocess.check_call([sys.executable, CMSCMP] + list(args), **kw)
28 28
29 29
30 def hg(*args, **kw): 30 def hg(*args, **kw):
tlucas 2017/11/24 10:57:46 This is a copy of cms_cmp.hg(), without the call o
Vasily Kuznetsov 2017/11/28 16:53:37 I had in mind three arguments for implementing a s
tlucas 2017/12/14 10:30:42 I agree, right now this is not a very urgent topic
31 cmd = ['hg'] 31 cmd = ['hg']
32 if 'repo' in kw: 32 if 'repo' in kw:
33 cmd += ['-R', kw['repo']] 33 cmd += ['-R', kw['repo']]
34 del kw['repo'] 34 del kw['repo']
35 # Disable default options from local user config. 35 # Disable default options from local user config.
36 cmd += ['--config', 'defaults.{}='.format(args[0])] 36 cmd += ['--config', 'defaults.{}='.format(args[0])]
37 return subprocess.check_call(cmd + list(args), **kw) 37 return subprocess.check_call(cmd + list(args), **kw)
38 38
39 39
40 @pytest.fixture(scope='session') 40 @pytest.fixture(scope='session')
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 with pytest.raises(subprocess.CalledProcessError): 111 with pytest.raises(subprocess.CalledProcessError):
112 run_cms_cmp('-d', str(tmpdir), '-c', str(cms), '-t', 'yoda', 112 run_cms_cmp('-d', str(tmpdir), '-c', str(cms), '-t', 'yoda',
113 str(website)) 113 str(website))
114 # ...but it will succeed if we tell it to delete old outputs. 114 # ...but it will succeed if we tell it to delete old outputs.
115 run_cms_cmp('-d', str(tmpdir), '-c', str(cms), '-t', 'yoda', '-r', 115 run_cms_cmp('-d', str(tmpdir), '-c', str(cms), '-t', 'yoda', '-r',
116 str(website)) 116 str(website))
117 117
118 118
119 def test_working_copy(website, cms, tmpdir): 119 def test_working_copy(website, cms, tmpdir):
120 with pytest.raises(subprocess.CalledProcessError): 120 with pytest.raises(subprocess.CalledProcessError):
121 # This will fail because surrent version is 'other'. 121 # This will fail because current version is 'other'.
tlucas 2017/11/24 10:57:46 typo "current"
Vasily Kuznetsov 2017/11/28 16:53:37 Done.
122 run_cms_cmp('-d', str(tmpdir), '-c', str(cms), str(website)) 122 run_cms_cmp('-d', str(tmpdir), '-c', str(cms), str(website))
123 generate = cms.join('cms').join('bin').join('generate_static_pages.py') 123 generate = cms.join('cms').join('bin').join('generate_static_pages.py')
124 # Remove last line that breaks stuff. 124 # Remove last line that breaks stuff.
125 generate.write('\n'.join(generate.read().splitlines()[:-1])) 125 generate.write('\n'.join(generate.read().splitlines()[:-1]))
126 # Now it should be better. 126 # Now it should be better.
127 run_cms_cmp('-d', str(tmpdir), '-c', str(cms), str(website)) 127 run_cms_cmp('-d', str(tmpdir), '-c', str(cms), str(website))
LEFTRIGHT

Powered by Google App Engine
This is Rietveld