Skip to content

Commit 9764c25

Browse files
committed
benchmarks root must be subdir of tests root
1 parent 20890fa commit 9764c25

File tree

3 files changed

+39
-36
lines changed

3 files changed

+39
-36
lines changed
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# import unittest
2-
#
3-
# from code_to_optimize.bubble_sort import sorter
4-
#
5-
#
6-
# class TestPigLatin(unittest.TestCase):
7-
# def test_sort(self):
8-
# input = [5, 4, 3, 2, 1, 0]
9-
# output = sorter(input)
10-
# self.assertEqual(output, [0, 1, 2, 3, 4, 5])
11-
#
12-
# input = [5.0, 4.0, 3.0, 2.0, 1.0, 0.0]
13-
# output = sorter(input)
14-
# self.assertEqual(output, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0])
15-
#
16-
# input = list(reversed(range(5000)))
17-
# output = sorter(input)
18-
# self.assertEqual(output, list(range(5000)))
1+
import unittest
2+
3+
from code_to_optimize.bubble_sort import sorter
4+
5+
6+
class TestPigLatin(unittest.TestCase):
7+
def test_sort(self):
8+
input = [5, 4, 3, 2, 1, 0]
9+
output = sorter(input)
10+
self.assertEqual(output, [0, 1, 2, 3, 4, 5])
11+
12+
input = [5.0, 4.0, 3.0, 2.0, 1.0, 0.0]
13+
output = sorter(input)
14+
self.assertEqual(output, [0.0, 1.0, 2.0, 3.0, 4.0, 5.0])
15+
16+
input = list(reversed(range(5000)))
17+
output = sorter(input)
18+
self.assertEqual(output, list(range(5000)))
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# import unittest
2-
#
3-
# from parameterized import parameterized
4-
#
5-
# from code_to_optimize.bubble_sort import sorter
6-
#
7-
#
8-
# class TestPigLatin(unittest.TestCase):
9-
# @parameterized.expand(
10-
# [
11-
# ([5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5]),
12-
# ([5.0, 4.0, 3.0, 2.0, 1.0, 0.0], [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]),
13-
# (list(reversed(range(50))), list(range(50))),
14-
# ]
15-
# )
16-
# def test_sort(self, input, expected_output):
17-
# output = sorter(input)
18-
# self.assertEqual(output, expected_output)
1+
import unittest
2+
3+
from parameterized import parameterized
4+
5+
from code_to_optimize.bubble_sort import sorter
6+
7+
8+
class TestPigLatin(unittest.TestCase):
9+
@parameterized.expand(
10+
[
11+
([5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5]),
12+
([5.0, 4.0, 3.0, 2.0, 1.0, 0.0], [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]),
13+
(list(reversed(range(50))), list(range(50))),
14+
]
15+
)
16+
def test_sort(self, input, expected_output):
17+
output = sorter(input)
18+
self.assertEqual(output, expected_output)

codeflash/cli_cmds/cli.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ def process_pyproject_config(args: Namespace) -> Namespace:
135135
if args.benchmark:
136136
assert args.benchmarks_root is not None, "--benchmarks-root must be specified when running with --benchmark"
137137
assert Path(args.benchmarks_root).is_dir(), f"--benchmarks-root {args.benchmarks_root} must be a valid directory"
138+
assert Path(args.benchmarks_root).is_relative_to(Path(args.tests_root)), (
139+
f"--benchmarks-root {args.benchmarks_root} must be a subdirectory of --tests-root {args.tests_root}"
140+
)
138141
if env_utils.get_pr_number() is not None:
139142
assert env_utils.ensure_codeflash_api_key(), (
140143
"Codeflash API key not found. When running in a Github Actions Context, provide the "

0 commit comments

Comments
 (0)