summaryrefslogtreecommitdiffstats
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-06 14:38:14 +0100
commit17266ae2dd2c5a22c7af84427b0ca11de481c21d (patch)
tree9940ef89f40e7d6b35dd931b4d3e0e416ddcb63e
parentd58c365a0718df6c4929eacd9f1df37459d28fa6 (diff)
downloadpoky-17266ae2dd2c5a22c7af84427b0ca11de481c21d.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: 501b5b7f338396a4a115355b8a78ae5b03f67d9a) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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'],