summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2017-06-27 17:33:42 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-27 22:36:44 +0100
commit026586965aebe5758dac9647a2ec3856f6d1cf8a (patch)
treec36f579f3341a1f186c43823acd240358e89a781 /scripts
parent8f20c03dd6dfecb58deb1069e8ab7af91f2cfcdb (diff)
downloadpoky-026586965aebe5758dac9647a2ec3856f6d1cf8a.tar.gz
yocto-compat-layer.py: allow README with suffix
It may be useful to append a suffix denoting the file format. For example, README.rst is rendered differently when viewed on Github, and also helps editors to switch to a mode more suitable for the format. The tests uses a file pattern to find the README file(s) and treats the one with the shortest name as the main one which must not be empty. (From OE-Core rev: 0abc29f135d7f870168d9676395f3a4bb77174b8) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/compatlayer/cases/common.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/scripts/lib/compatlayer/cases/common.py b/scripts/lib/compatlayer/cases/common.py
index ede002d50d..4c8a5439ec 100644
--- a/scripts/lib/compatlayer/cases/common.py
+++ b/scripts/lib/compatlayer/cases/common.py
@@ -1,6 +1,7 @@
1# Copyright (C) 2017 Intel Corporation 1# Copyright (C) 2017 Intel Corporation
2# Released under the MIT license (see COPYING.MIT) 2# Released under the MIT license (see COPYING.MIT)
3 3
4import glob
4import os 5import os
5import unittest 6import unittest
6from compatlayer import get_signatures, LayerType, check_command, get_depgraph 7from compatlayer import get_signatures, LayerType, check_command, get_depgraph
@@ -8,15 +9,20 @@ from compatlayer.case import OECompatLayerTestCase
8 9
9class CommonCompatLayer(OECompatLayerTestCase): 10class CommonCompatLayer(OECompatLayerTestCase):
10 def test_readme(self): 11 def test_readme(self):
11 readme_file = os.path.join(self.tc.layer['path'], 'README') 12 # The top-level README file may have a suffix (like README.rst or README.txt).
12 self.assertTrue(os.path.isfile(readme_file), 13 readme_files = glob.glob(os.path.join(self.tc.layer['path'], 'README*'))
13 msg="Layer doesn't contains README file.") 14 self.assertTrue(len(readme_files) > 0,
15 msg="Layer doesn't contains README file.")
14 16
17 # There might be more than one file matching the file pattern above
18 # (for example, README.rst and README-COPYING.rst). The one with the shortest
19 # name is considered the "main" one.
20 readme_file = sorted(readme_files)[0]
15 data = '' 21 data = ''
16 with open(readme_file, 'r') as f: 22 with open(readme_file, 'r') as f:
17 data = f.read() 23 data = f.read()
18 self.assertTrue(data, 24 self.assertTrue(data,
19 msg="Layer contains README file but is empty.") 25 msg="Layer contains a README file but it is empty.")
20 26
21 def test_parse(self): 27 def test_parse(self):
22 check_command('Layer %s failed to parse.' % self.tc.layer['name'], 28 check_command('Layer %s failed to parse.' % self.tc.layer['name'],