-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expand ${var} in benchcomp variant
env
The values of environment variables in the benchcomp configuration file can now contain strings of the form '${var}'. Benchcomp will replace these strings with the value of the environment variable 'var'. This is intended to allow users to have several benchcomp variants, each of which differs only in the environment. This fixes #2981.
- Loading branch information
Showing
4 changed files
with
170 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
# | ||
# Benchcomp regression testing suite. This suite uses Python's stdlib unittest | ||
# module, but nevertheless actually runs the binary rather than running unit | ||
# tests. | ||
|
||
import unittest | ||
import uuid | ||
|
||
import benchcomp.entry.run | ||
|
||
|
||
|
||
class TestEnvironmentUpdater(unittest.TestCase): | ||
def test_environment_construction(self): | ||
"""Test that the default constructor reads the OS environment""" | ||
|
||
update_environment = benchcomp.entry.run._EnvironmentUpdater() | ||
environment = update_environment({}) | ||
self.assertIn("PATH", environment) | ||
|
||
|
||
def test_placeholder_construction(self): | ||
"""Test that the placeholder constructor reads the placeholder""" | ||
|
||
key, value = [str(uuid.uuid4()) for _ in range(2)] | ||
update_environment = benchcomp.entry.run._EnvironmentUpdater({ | ||
key: value, | ||
}) | ||
environment = update_environment({}) | ||
self.assertIn(key, environment) | ||
self.assertEqual(environment[key], value) | ||
|
||
|
||
def test_environment_update(self): | ||
"""Test that the environment is updated""" | ||
|
||
key, value, update = [str(uuid.uuid4()) for _ in range(3)] | ||
update_environment = benchcomp.entry.run._EnvironmentUpdater({ | ||
key: value, | ||
}) | ||
environment = update_environment({ | ||
key: update | ||
}) | ||
self.assertIn(key, environment) | ||
self.assertEqual(environment[key], update) | ||
|
||
|
||
def test_environment_update_variable(self): | ||
"""Test that the environment is updated""" | ||
|
||
old_env = { | ||
"key1": str(uuid.uuid4()), | ||
"key2": str(uuid.uuid4()), | ||
} | ||
|
||
actual_update = "${key2}xxx${key1}" | ||
expected_update = f"{old_env['key2']}xxx{old_env['key1']}" | ||
|
||
update_environment = benchcomp.entry.run._EnvironmentUpdater(old_env) | ||
environment = update_environment({ | ||
"key1": actual_update, | ||
}) | ||
self.assertIn("key1", environment) | ||
self.assertEqual(environment["key1"], expected_update) |