on xenial help sign in
Add import test
1a33af9Andrea Cimitan
qml/Launcher/LauncherPanel.qml+1−1
@@ -19,7 +19,7 @@ import Ubuntu.Components 1.3
19import Unity.Launcher 0.1
19import Unity.Launcher 0.1
20import Ubuntu.Components.Popups 1.3
20import Ubuntu.Components.Popups 1.3
21import "../Components/ListItems"
21import "../Components/ListItems"
22−import "../Components/"
22+import "../Components"
23
23
24Rectangle {
24Rectangle {
25 id: root
25 id: root
tests/imports/check_imports.py+45
@@ -81,6 +81,48 @@ def scan_for_bad_import(file_path, all_pat, good_pats):
81 print("%s: bad import version in multiple lines" % file_path)
81 print("%s: bad import version in multiple lines" % file_path)
82 return bool(errors)
82 return bool(errors)
83
83
84+# Flickable matches
85+flickable_pat = re.compile(r'.*\ Flickable {')
86+listview_pat = re.compile(r'.*\ ListView {')
87+gridview_pat = re.compile(r'.*\ GridView {')
88+flickable_pats = [flickable_pat, listview_pat, gridview_pat]
89+unity_components_pat = re.compile(r'.*import ".*Components"')
90+components_path = re.compile(r'.*qml/Components.*')
91+
92+def scan_for_flickable_imports(file_path, component_pats, qtquick_pat, uitk_pat):
93+ errors = []
94+ with open(file_path, 'rt', encoding='utf-8') as ifile, open(file_path, 'rt', encoding='utf-8') as i2file:
95+ flickable_found = False
96+ for lino, line in enumerate(ifile, start=1):
97+ for component_pat in component_pats:
98+ if component_pat.match(line):
99+ flickable_found = True
100+ if flickable_found:
101+ qtquick_found = False
102+ uitk_found = False
103+ for lino, line in enumerate(i2file, start=1):
104+ if not qtquick_found and qtquick_pat.match(line):
105+ qtquick_found = True
106+ if uitk_pat.match(line):
107+ uitk_found = True
108+ if not qtquick_found:
109+ errors.append(lino)
110+ else:
111+ return
112+ if not uitk_found:
113+ errors.append(lino)
114+ if 0 < len(errors) <= 10:
115+ if len(errors) > 1:
116+ plural = 's'
117+ else:
118+ plural = ''
119+ print(
120+ "%s: bad import version in line%s %s" % (
121+ file_path, plural, ", ".join((str(i) for i in errors))))
122+ elif errors:
123+ print("%s: bad import version in multiple lines" % file_path)
124+ return bool(errors)
125+
84# Parse args
126# Parse args
85
127
86parser = argparse.ArgumentParser(
128parser = argparse.ArgumentParser(
@@ -116,6 +158,9 @@ try:
116 found_bad_import = True
158 found_bad_import = True
117 if scan_for_bad_import(path, ubuntu_components_pat, [ubuntu_good_components_pat]):
159 if scan_for_bad_import(path, ubuntu_components_pat, [ubuntu_good_components_pat]):
118 found_bad_import = True
160 found_bad_import = True
161+ if not components_path.match(path):
162+ if scan_for_flickable_imports(path, flickable_pats, quick_good_pat, unity_components_pat):
163+ found_bad_import = True
119
164
120except OSError as e:
165except OSError as e:
121 error("cannot create file list for \"" + dir + "\": " + e.strerror)
166 error("cannot create file list for \"" + dir + "\": " + e.strerror)