Skip to content

Commit

Permalink
Non valued build variable bugfix (#441)
Browse files Browse the repository at this point in the history
Non valued build variables could incorrectly be created when specifying
a variable's value be "" (var_dict.SetValue("VAR_NAME", "", "Comment")).
Non-valued build variables should only be created when setting a
build variables value to None:
(var_dict.SetValue("VAR_NAME", None, "Comment)).

This commit fixes the check to only create a non-valued build variable
when the variable value is None.
  • Loading branch information
Javagedes authored Feb 9, 2023
1 parent 51454d8 commit f95cbf3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion edk2toolext/environment/var_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def SetValue(self, k, v, comment, overridable=False):
"""
key = k.upper()
en = self.GetEntry(key)
if not v:
if v is None:
value = ''.join(choice(ascii_letters) for _ in range(20))
else:
value = str(v)
Expand Down
8 changes: 8 additions & 0 deletions edk2toolext/tests/test_var_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ def test_var_dict_print_all(self):
v.SetValue("test2", "value1", "test 1 comment overrideable", True)
v.PrintAll()

def test_var_dict_non_valued_var(self):
v = var_dict.VarDict()
v.SetValue("var1", "", "Test Comment")
self.assertEqual(v.GetValue("var1"), "")
v.SetValue("var2", None, "Test Comment")
self.assertNotEqual(v.GetValue("var2"), None)
self.failIf(not v.GetValue("var2"), "Should return True")


if __name__ == '__main__':
unittest.main()

0 comments on commit f95cbf3

Please sign in to comment.