diff options
Diffstat (limited to 'bitbake/lib/bb/tests/data.py')
-rw-r--r-- | bitbake/lib/bb/tests/data.py | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py index b54eb06797..1a5a28af06 100644 --- a/bitbake/lib/bb/tests/data.py +++ b/bitbake/lib/bb/tests/data.py | |||
@@ -77,13 +77,13 @@ class DataExpansions(unittest.TestCase): | |||
77 | self.assertEqual(str(val), "boo value_of_foo") | 77 | self.assertEqual(str(val), "boo value_of_foo") |
78 | 78 | ||
79 | def test_python_snippet_getvar(self): | 79 | def test_python_snippet_getvar(self): |
80 | val = self.d.expand("${@d.getVar('foo', True) + ' ${bar}'}") | 80 | val = self.d.expand("${@d.getVar('foo') + ' ${bar}'}") |
81 | self.assertEqual(str(val), "value_of_foo value_of_bar") | 81 | self.assertEqual(str(val), "value_of_foo value_of_bar") |
82 | 82 | ||
83 | def test_python_unexpanded(self): | 83 | def test_python_unexpanded(self): |
84 | self.d.setVar("bar", "${unsetvar}") | 84 | self.d.setVar("bar", "${unsetvar}") |
85 | val = self.d.expand("${@d.getVar('foo', True) + ' ${bar}'}") | 85 | val = self.d.expand("${@d.getVar('foo') + ' ${bar}'}") |
86 | self.assertEqual(str(val), "${@d.getVar('foo', True) + ' ${unsetvar}'}") | 86 | self.assertEqual(str(val), "${@d.getVar('foo') + ' ${unsetvar}'}") |
87 | 87 | ||
88 | def test_python_snippet_syntax_error(self): | 88 | def test_python_snippet_syntax_error(self): |
89 | self.d.setVar("FOO", "${@foo = 5}") | 89 | self.d.setVar("FOO", "${@foo = 5}") |
@@ -99,7 +99,7 @@ class DataExpansions(unittest.TestCase): | |||
99 | self.assertRaises(bb.data_smart.ExpansionError, self.d.getVar, "FOO", True) | 99 | self.assertRaises(bb.data_smart.ExpansionError, self.d.getVar, "FOO", True) |
100 | 100 | ||
101 | def test_value_containing_value(self): | 101 | def test_value_containing_value(self): |
102 | val = self.d.expand("${@d.getVar('foo', True) + ' ${bar}'}") | 102 | val = self.d.expand("${@d.getVar('foo') + ' ${bar}'}") |
103 | self.assertEqual(str(val), "value_of_foo value_of_bar") | 103 | self.assertEqual(str(val), "value_of_foo value_of_bar") |
104 | 104 | ||
105 | def test_reference_undefined_var(self): | 105 | def test_reference_undefined_var(self): |
@@ -109,7 +109,7 @@ class DataExpansions(unittest.TestCase): | |||
109 | def test_double_reference(self): | 109 | def test_double_reference(self): |
110 | self.d.setVar("BAR", "bar value") | 110 | self.d.setVar("BAR", "bar value") |
111 | self.d.setVar("FOO", "${BAR} foo ${BAR}") | 111 | self.d.setVar("FOO", "${BAR} foo ${BAR}") |
112 | val = self.d.getVar("FOO", True) | 112 | val = self.d.getVar("FOO") |
113 | self.assertEqual(str(val), "bar value foo bar value") | 113 | self.assertEqual(str(val), "bar value foo bar value") |
114 | 114 | ||
115 | def test_direct_recursion(self): | 115 | def test_direct_recursion(self): |
@@ -129,12 +129,12 @@ class DataExpansions(unittest.TestCase): | |||
129 | 129 | ||
130 | def test_incomplete_varexp_single_quotes(self): | 130 | def test_incomplete_varexp_single_quotes(self): |
131 | self.d.setVar("FOO", "sed -i -e 's:IP{:I${:g' $pc") | 131 | self.d.setVar("FOO", "sed -i -e 's:IP{:I${:g' $pc") |
132 | val = self.d.getVar("FOO", True) | 132 | val = self.d.getVar("FOO") |
133 | self.assertEqual(str(val), "sed -i -e 's:IP{:I${:g' $pc") | 133 | self.assertEqual(str(val), "sed -i -e 's:IP{:I${:g' $pc") |
134 | 134 | ||
135 | def test_nonstring(self): | 135 | def test_nonstring(self): |
136 | self.d.setVar("TEST", 5) | 136 | self.d.setVar("TEST", 5) |
137 | val = self.d.getVar("TEST", True) | 137 | val = self.d.getVar("TEST") |
138 | self.assertEqual(str(val), "5") | 138 | self.assertEqual(str(val), "5") |
139 | 139 | ||
140 | def test_rename(self): | 140 | def test_rename(self): |
@@ -234,19 +234,19 @@ class TestConcat(unittest.TestCase): | |||
234 | def test_prepend(self): | 234 | def test_prepend(self): |
235 | self.d.setVar("TEST", "${VAL}") | 235 | self.d.setVar("TEST", "${VAL}") |
236 | self.d.prependVar("TEST", "${FOO}:") | 236 | self.d.prependVar("TEST", "${FOO}:") |
237 | self.assertEqual(self.d.getVar("TEST", True), "foo:val") | 237 | self.assertEqual(self.d.getVar("TEST"), "foo:val") |
238 | 238 | ||
239 | def test_append(self): | 239 | def test_append(self): |
240 | self.d.setVar("TEST", "${VAL}") | 240 | self.d.setVar("TEST", "${VAL}") |
241 | self.d.appendVar("TEST", ":${BAR}") | 241 | self.d.appendVar("TEST", ":${BAR}") |
242 | self.assertEqual(self.d.getVar("TEST", True), "val:bar") | 242 | self.assertEqual(self.d.getVar("TEST"), "val:bar") |
243 | 243 | ||
244 | def test_multiple_append(self): | 244 | def test_multiple_append(self): |
245 | self.d.setVar("TEST", "${VAL}") | 245 | self.d.setVar("TEST", "${VAL}") |
246 | self.d.prependVar("TEST", "${FOO}:") | 246 | self.d.prependVar("TEST", "${FOO}:") |
247 | self.d.appendVar("TEST", ":val2") | 247 | self.d.appendVar("TEST", ":val2") |
248 | self.d.appendVar("TEST", ":${BAR}") | 248 | self.d.appendVar("TEST", ":${BAR}") |
249 | self.assertEqual(self.d.getVar("TEST", True), "foo:val:val2:bar") | 249 | self.assertEqual(self.d.getVar("TEST"), "foo:val:val2:bar") |
250 | 250 | ||
251 | class TestConcatOverride(unittest.TestCase): | 251 | class TestConcatOverride(unittest.TestCase): |
252 | def setUp(self): | 252 | def setUp(self): |
@@ -259,13 +259,13 @@ class TestConcatOverride(unittest.TestCase): | |||
259 | self.d.setVar("TEST", "${VAL}") | 259 | self.d.setVar("TEST", "${VAL}") |
260 | self.d.setVar("TEST_prepend", "${FOO}:") | 260 | self.d.setVar("TEST_prepend", "${FOO}:") |
261 | bb.data.update_data(self.d) | 261 | bb.data.update_data(self.d) |
262 | self.assertEqual(self.d.getVar("TEST", True), "foo:val") | 262 | self.assertEqual(self.d.getVar("TEST"), "foo:val") |
263 | 263 | ||
264 | def test_append(self): | 264 | def test_append(self): |
265 | self.d.setVar("TEST", "${VAL}") | 265 | self.d.setVar("TEST", "${VAL}") |
266 | self.d.setVar("TEST_append", ":${BAR}") | 266 | self.d.setVar("TEST_append", ":${BAR}") |
267 | bb.data.update_data(self.d) | 267 | bb.data.update_data(self.d) |
268 | self.assertEqual(self.d.getVar("TEST", True), "val:bar") | 268 | self.assertEqual(self.d.getVar("TEST"), "val:bar") |
269 | 269 | ||
270 | def test_multiple_append(self): | 270 | def test_multiple_append(self): |
271 | self.d.setVar("TEST", "${VAL}") | 271 | self.d.setVar("TEST", "${VAL}") |
@@ -273,47 +273,47 @@ class TestConcatOverride(unittest.TestCase): | |||
273 | self.d.setVar("TEST_append", ":val2") | 273 | self.d.setVar("TEST_append", ":val2") |
274 | self.d.setVar("TEST_append", ":${BAR}") | 274 | self.d.setVar("TEST_append", ":${BAR}") |
275 | bb.data.update_data(self.d) | 275 | bb.data.update_data(self.d) |
276 | self.assertEqual(self.d.getVar("TEST", True), "foo:val:val2:bar") | 276 | self.assertEqual(self.d.getVar("TEST"), "foo:val:val2:bar") |
277 | 277 | ||
278 | def test_append_unset(self): | 278 | def test_append_unset(self): |
279 | self.d.setVar("TEST_prepend", "${FOO}:") | 279 | self.d.setVar("TEST_prepend", "${FOO}:") |
280 | self.d.setVar("TEST_append", ":val2") | 280 | self.d.setVar("TEST_append", ":val2") |
281 | self.d.setVar("TEST_append", ":${BAR}") | 281 | self.d.setVar("TEST_append", ":${BAR}") |
282 | bb.data.update_data(self.d) | 282 | bb.data.update_data(self.d) |
283 | self.assertEqual(self.d.getVar("TEST", True), "foo::val2:bar") | 283 | self.assertEqual(self.d.getVar("TEST"), "foo::val2:bar") |
284 | 284 | ||
285 | def test_remove(self): | 285 | def test_remove(self): |
286 | self.d.setVar("TEST", "${VAL} ${BAR}") | 286 | self.d.setVar("TEST", "${VAL} ${BAR}") |
287 | self.d.setVar("TEST_remove", "val") | 287 | self.d.setVar("TEST_remove", "val") |
288 | bb.data.update_data(self.d) | 288 | bb.data.update_data(self.d) |
289 | self.assertEqual(self.d.getVar("TEST", True), "bar") | 289 | self.assertEqual(self.d.getVar("TEST"), "bar") |
290 | 290 | ||
291 | def test_doubleref_remove(self): | 291 | def test_doubleref_remove(self): |
292 | self.d.setVar("TEST", "${VAL} ${BAR}") | 292 | self.d.setVar("TEST", "${VAL} ${BAR}") |
293 | self.d.setVar("TEST_remove", "val") | 293 | self.d.setVar("TEST_remove", "val") |
294 | self.d.setVar("TEST_TEST", "${TEST} ${TEST}") | 294 | self.d.setVar("TEST_TEST", "${TEST} ${TEST}") |
295 | bb.data.update_data(self.d) | 295 | bb.data.update_data(self.d) |
296 | self.assertEqual(self.d.getVar("TEST_TEST", True), "bar bar") | 296 | self.assertEqual(self.d.getVar("TEST_TEST"), "bar bar") |
297 | 297 | ||
298 | def test_empty_remove(self): | 298 | def test_empty_remove(self): |
299 | self.d.setVar("TEST", "") | 299 | self.d.setVar("TEST", "") |
300 | self.d.setVar("TEST_remove", "val") | 300 | self.d.setVar("TEST_remove", "val") |
301 | bb.data.update_data(self.d) | 301 | bb.data.update_data(self.d) |
302 | self.assertEqual(self.d.getVar("TEST", True), "") | 302 | self.assertEqual(self.d.getVar("TEST"), "") |
303 | 303 | ||
304 | def test_remove_expansion(self): | 304 | def test_remove_expansion(self): |
305 | self.d.setVar("BAR", "Z") | 305 | self.d.setVar("BAR", "Z") |
306 | self.d.setVar("TEST", "${BAR}/X Y") | 306 | self.d.setVar("TEST", "${BAR}/X Y") |
307 | self.d.setVar("TEST_remove", "${BAR}/X") | 307 | self.d.setVar("TEST_remove", "${BAR}/X") |
308 | bb.data.update_data(self.d) | 308 | bb.data.update_data(self.d) |
309 | self.assertEqual(self.d.getVar("TEST", True), "Y") | 309 | self.assertEqual(self.d.getVar("TEST"), "Y") |
310 | 310 | ||
311 | def test_remove_expansion_items(self): | 311 | def test_remove_expansion_items(self): |
312 | self.d.setVar("TEST", "A B C D") | 312 | self.d.setVar("TEST", "A B C D") |
313 | self.d.setVar("BAR", "B D") | 313 | self.d.setVar("BAR", "B D") |
314 | self.d.setVar("TEST_remove", "${BAR}") | 314 | self.d.setVar("TEST_remove", "${BAR}") |
315 | bb.data.update_data(self.d) | 315 | bb.data.update_data(self.d) |
316 | self.assertEqual(self.d.getVar("TEST", True), "A C") | 316 | self.assertEqual(self.d.getVar("TEST"), "A C") |
317 | 317 | ||
318 | class TestOverrides(unittest.TestCase): | 318 | class TestOverrides(unittest.TestCase): |
319 | def setUp(self): | 319 | def setUp(self): |
@@ -323,17 +323,17 @@ class TestOverrides(unittest.TestCase): | |||
323 | 323 | ||
324 | def test_no_override(self): | 324 | def test_no_override(self): |
325 | bb.data.update_data(self.d) | 325 | bb.data.update_data(self.d) |
326 | self.assertEqual(self.d.getVar("TEST", True), "testvalue") | 326 | self.assertEqual(self.d.getVar("TEST"), "testvalue") |
327 | 327 | ||
328 | def test_one_override(self): | 328 | def test_one_override(self): |
329 | self.d.setVar("TEST_bar", "testvalue2") | 329 | self.d.setVar("TEST_bar", "testvalue2") |
330 | bb.data.update_data(self.d) | 330 | bb.data.update_data(self.d) |
331 | self.assertEqual(self.d.getVar("TEST", True), "testvalue2") | 331 | self.assertEqual(self.d.getVar("TEST"), "testvalue2") |
332 | 332 | ||
333 | def test_one_override_unset(self): | 333 | def test_one_override_unset(self): |
334 | self.d.setVar("TEST2_bar", "testvalue2") | 334 | self.d.setVar("TEST2_bar", "testvalue2") |
335 | bb.data.update_data(self.d) | 335 | bb.data.update_data(self.d) |
336 | self.assertEqual(self.d.getVar("TEST2", True), "testvalue2") | 336 | self.assertEqual(self.d.getVar("TEST2"), "testvalue2") |
337 | self.assertCountEqual(list(self.d.keys()), ['TEST', 'TEST2', 'OVERRIDES', 'TEST2_bar']) | 337 | self.assertCountEqual(list(self.d.keys()), ['TEST', 'TEST2', 'OVERRIDES', 'TEST2_bar']) |
338 | 338 | ||
339 | def test_multiple_override(self): | 339 | def test_multiple_override(self): |
@@ -341,18 +341,18 @@ class TestOverrides(unittest.TestCase): | |||
341 | self.d.setVar("TEST_local", "testvalue3") | 341 | self.d.setVar("TEST_local", "testvalue3") |
342 | self.d.setVar("TEST_foo", "testvalue4") | 342 | self.d.setVar("TEST_foo", "testvalue4") |
343 | bb.data.update_data(self.d) | 343 | bb.data.update_data(self.d) |
344 | self.assertEqual(self.d.getVar("TEST", True), "testvalue3") | 344 | self.assertEqual(self.d.getVar("TEST"), "testvalue3") |
345 | self.assertCountEqual(list(self.d.keys()), ['TEST', 'TEST_foo', 'OVERRIDES', 'TEST_bar', 'TEST_local']) | 345 | self.assertCountEqual(list(self.d.keys()), ['TEST', 'TEST_foo', 'OVERRIDES', 'TEST_bar', 'TEST_local']) |
346 | 346 | ||
347 | def test_multiple_combined_overrides(self): | 347 | def test_multiple_combined_overrides(self): |
348 | self.d.setVar("TEST_local_foo_bar", "testvalue3") | 348 | self.d.setVar("TEST_local_foo_bar", "testvalue3") |
349 | bb.data.update_data(self.d) | 349 | bb.data.update_data(self.d) |
350 | self.assertEqual(self.d.getVar("TEST", True), "testvalue3") | 350 | self.assertEqual(self.d.getVar("TEST"), "testvalue3") |
351 | 351 | ||
352 | def test_multiple_overrides_unset(self): | 352 | def test_multiple_overrides_unset(self): |
353 | self.d.setVar("TEST2_local_foo_bar", "testvalue3") | 353 | self.d.setVar("TEST2_local_foo_bar", "testvalue3") |
354 | bb.data.update_data(self.d) | 354 | bb.data.update_data(self.d) |
355 | self.assertEqual(self.d.getVar("TEST2", True), "testvalue3") | 355 | self.assertEqual(self.d.getVar("TEST2"), "testvalue3") |
356 | 356 | ||
357 | def test_keyexpansion_override(self): | 357 | def test_keyexpansion_override(self): |
358 | self.d.setVar("LOCAL", "local") | 358 | self.d.setVar("LOCAL", "local") |
@@ -361,21 +361,21 @@ class TestOverrides(unittest.TestCase): | |||
361 | self.d.setVar("TEST_foo", "testvalue4") | 361 | self.d.setVar("TEST_foo", "testvalue4") |
362 | bb.data.update_data(self.d) | 362 | bb.data.update_data(self.d) |
363 | bb.data.expandKeys(self.d) | 363 | bb.data.expandKeys(self.d) |
364 | self.assertEqual(self.d.getVar("TEST", True), "testvalue3") | 364 | self.assertEqual(self.d.getVar("TEST"), "testvalue3") |
365 | 365 | ||
366 | def test_rename_override(self): | 366 | def test_rename_override(self): |
367 | self.d.setVar("ALTERNATIVE_ncurses-tools_class-target", "a") | 367 | self.d.setVar("ALTERNATIVE_ncurses-tools_class-target", "a") |
368 | self.d.setVar("OVERRIDES", "class-target") | 368 | self.d.setVar("OVERRIDES", "class-target") |
369 | bb.data.update_data(self.d) | 369 | bb.data.update_data(self.d) |
370 | self.d.renameVar("ALTERNATIVE_ncurses-tools", "ALTERNATIVE_lib32-ncurses-tools") | 370 | self.d.renameVar("ALTERNATIVE_ncurses-tools", "ALTERNATIVE_lib32-ncurses-tools") |
371 | self.assertEqual(self.d.getVar("ALTERNATIVE_lib32-ncurses-tools", True), "a") | 371 | self.assertEqual(self.d.getVar("ALTERNATIVE_lib32-ncurses-tools"), "a") |
372 | 372 | ||
373 | def test_underscore_override(self): | 373 | def test_underscore_override(self): |
374 | self.d.setVar("TEST_bar", "testvalue2") | 374 | self.d.setVar("TEST_bar", "testvalue2") |
375 | self.d.setVar("TEST_some_val", "testvalue3") | 375 | self.d.setVar("TEST_some_val", "testvalue3") |
376 | self.d.setVar("TEST_foo", "testvalue4") | 376 | self.d.setVar("TEST_foo", "testvalue4") |
377 | self.d.setVar("OVERRIDES", "foo:bar:some_val") | 377 | self.d.setVar("OVERRIDES", "foo:bar:some_val") |
378 | self.assertEqual(self.d.getVar("TEST", True), "testvalue3") | 378 | self.assertEqual(self.d.getVar("TEST"), "testvalue3") |
379 | 379 | ||
380 | class TestKeyExpansion(unittest.TestCase): | 380 | class TestKeyExpansion(unittest.TestCase): |
381 | def setUp(self): | 381 | def setUp(self): |
@@ -389,7 +389,7 @@ class TestKeyExpansion(unittest.TestCase): | |||
389 | with LogRecord() as logs: | 389 | with LogRecord() as logs: |
390 | bb.data.expandKeys(self.d) | 390 | bb.data.expandKeys(self.d) |
391 | self.assertTrue(logContains("Variable key VAL_${FOO} (A) replaces original key VAL_foo (B)", logs)) | 391 | self.assertTrue(logContains("Variable key VAL_${FOO} (A) replaces original key VAL_foo (B)", logs)) |
392 | self.assertEqual(self.d.getVar("VAL_foo", True), "A") | 392 | self.assertEqual(self.d.getVar("VAL_foo"), "A") |
393 | 393 | ||
394 | class TestFlags(unittest.TestCase): | 394 | class TestFlags(unittest.TestCase): |
395 | def setUp(self): | 395 | def setUp(self): |