Skip to content

Commit df7a7c1

Browse files
#134 Fix review comments
- update env variable string parsing - continue loading files even if some directories are incorrect - add test for default logic
1 parent 56c6826 commit df7a7c1

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

getgauge/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
PROJECT_ROOT_ENV = 'GAUGE_PROJECT_ROOT'
44
STEP_IMPL_DIR_ENV = 'STEP_IMPL_DIR'
5-
STEP_IMPL_DIR_NAMES = os.getenv(STEP_IMPL_DIR_ENV).split(',') if os.getenv(STEP_IMPL_DIR_ENV) else ['step_impl']
65

76

87
def get_project_root():
@@ -13,6 +12,7 @@ def get_project_root():
1312

1413

1514
def get_step_impl_dirs():
15+
STEP_IMPL_DIR_NAMES = map(str.strip, os.getenv(STEP_IMPL_DIR_ENV).split(',')) if os.getenv(STEP_IMPL_DIR_ENV) else ['step_impl']
1616
return [os.path.join(get_project_root(), name) for name in STEP_IMPL_DIR_NAMES]
1717

1818

start.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def load_implementations():
3232
for impl_dir in d:
3333
if not path.exists(impl_dir):
3434
logging.error('can not load implementations from {}. {} does not exist.'.format(impl_dir, impl_dir))
35-
return
3635
load_files(d)
3736

3837

tests/test_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
from unittest import main, TestCase
2+
from getgauge.util import get_step_impl_dirs
23
import os
34

45

56
class UtilTests(TestCase):
67

8+
def test_get_step_impl_gives_default_if_no_env_Set(self):
9+
dirs = get_step_impl_dirs()
10+
expected = ['step_impl']
11+
self.assertEquals(dirs,expected)
12+
713
def test_get_step_impl_returns_array_of_impl_dirs(self):
8-
os.environ["STEP_IMPL_DIR"] = "step_impl,step_impl1"
9-
from getgauge.util import get_step_impl_dirs
14+
os.environ["STEP_IMPL_DIR"] = "step_impl, step_impl1"
1015
dirs = get_step_impl_dirs()
1116
expected = ['step_impl','step_impl1']
1217
self.assertEquals(dirs,expected)

0 commit comments

Comments
 (0)