Skip to content

Commit

Permalink
Added failing test to show that we add single quotes around environme…
Browse files Browse the repository at this point in the history
…nt variable values

Signed-off-by: Stefan Marr <[email protected]>
  • Loading branch information
smarr committed Jan 27, 2025
1 parent 3b0bffe commit afa1468
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
22 changes: 22 additions & 0 deletions rebench/tests/bugs/env_quote.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
default_experiment: Test

benchmark_suites:
Suite:
gauge_adapter: Time
command: TestBenchMarks %(benchmark)s %(warmup)s
benchmarks:
- Bench1
env:
LUA_PATH: "?.lua;../../awfy/Lua/?.lua"

executors:
TestRunner1:
path: .
executable: env_quote_vm.py

experiments:
Test:
suites:
- Suite
executions:
- TestRunner1
43 changes: 43 additions & 0 deletions rebench/tests/bugs/env_quote_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (c) 2009-2025 Stefan Marr <https://www.stefan-marr.de/>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
from ...configurator import Configurator, load_config
from ...executor import Executor
from ...persistence import DataStore

from ..rebench_test_case import ReBenchTestCase


class EnvQuoteTest(ReBenchTestCase):

def setUp(self):
super(EnvQuoteTest, self).setUp()
self._set_path(__file__)

def test_execution_should_recognize_invalid_run_and_continue_normally(self):
cnf = Configurator(load_config(self._path + '/env_quote.conf'),
DataStore(self.ui),
self.ui, data_file=self._tmp_file)
runs = list(cnf.get_runs())
self.assertEqual(runs[0].get_number_of_data_points(), 0)

ex = Executor([runs[0]], False, self.ui)
ex.execute()

self.assertEqual(runs[0].get_number_of_data_points(), 1)
13 changes: 13 additions & 0 deletions rebench/tests/bugs/env_quote_vm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python3
import os
import sys

# get the environemnt variable LUA_PATH
lua_path = os.environ.get('LUA_PATH', '')
if lua_path == "?.lua;../../awfy/Lua/?.lua":
print("Correct")
sys.exit(0)
else:
print("Error: LUA_PATH has unexpected value: " + lua_path)
print("Previously we has stray single quotes around the value.")
sys.exit(1)

0 comments on commit afa1468

Please sign in to comment.