Skip to content

Commit 58e5681

Browse files
author
Vasileios Karakasis
committed
Always use $HOME for storing processor auto-detection results
1 parent e98078a commit 58e5681

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

reframe/frontend/autodetect.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,7 @@ def _emit_script(job):
154154
def detect_topology():
155155
rt = runtime()
156156
detect_remote_systems = rt.get_option('general/0/remote_detect')
157-
config_file = rt.site_config.filename
158-
if config_file == '<builtin>':
159-
config_prefix = os.path.join(
160-
os.getenv('HOME'), '.reframe/topology'
161-
)
162-
else:
163-
config_prefix = os.path.join(os.path.dirname(config_file), '_meta')
164-
157+
topo_prefix = os.path.join(os.getenv('HOME'), '.reframe/topology')
165158
for part in rt.system.partitions:
166159
getlogger().debug(f'detecting topology info for {part.fullname}')
167160
found_procinfo = False
@@ -184,10 +177,10 @@ def detect_topology():
184177
continue
185178

186179
topo_file = os.path.join(
187-
config_prefix, f'{rt.system.name}-{part.name}', 'processor.json'
180+
topo_prefix, f'{rt.system.name}-{part.name}', 'processor.json'
188181
)
189182
dev_file = os.path.join(
190-
config_prefix, f'{rt.system.name}-{part.name}', 'devices.json'
183+
topo_prefix, f'{rt.system.name}-{part.name}', 'devices.json'
191184
)
192185
if not found_procinfo and os.path.exists(topo_file):
193186
getlogger().debug(

unittests/test_autodetect.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@
1515

1616

1717
@pytest.fixture
18-
def exec_ctx(make_exec_ctx_g, tmp_path):
19-
# Copy the default settings to the temp dir
20-
config_file = tmp_path / 'conf.py'
21-
shutil.copy('reframe/core/settings.py', config_file)
18+
def exec_ctx(make_exec_ctx_g, tmp_path, monkeypatch):
19+
# Monkey-patch HOME, since topology is always written there
20+
monkeypatch.setenv('HOME', str(tmp_path))
2221

2322
# Create a devices file manually, since it is not auto-generated
24-
meta_prefix = tmp_path / '_meta' / 'generic-default'
23+
meta_prefix = tmp_path / '.reframe' / 'topology' / 'generic-default'
2524
os.makedirs(meta_prefix)
2625
with open(meta_prefix / 'devices.json', 'w') as fp:
2726
json.dump([
@@ -32,7 +31,7 @@ def exec_ctx(make_exec_ctx_g, tmp_path):
3231
}
3332
], fp)
3433

35-
yield from make_exec_ctx_g(config_file)
34+
yield from make_exec_ctx_g()
3635

3736

3837
def test_autotect(exec_ctx):

unittests/test_cli.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,7 @@ def perflogdir(tmp_path):
5454

5555

5656
@pytest.fixture
57-
def rm_config_meta():
58-
yield
59-
shutil.rmtree('unittests/resources/_meta', ignore_errors=True)
60-
61-
62-
@pytest.fixture
63-
def run_reframe(tmp_path, perflogdir, rm_config_meta):
57+
def run_reframe(tmp_path, perflogdir, monkeypatch):
6458
def _run_reframe(system='generic:default',
6559
checkpath=['unittests/resources/checks/hellocheck.py'],
6660
environs=['builtin'],
@@ -113,6 +107,7 @@ def _run_reframe(system='generic:default',
113107

114108
return run_command_inline(argv, cli.main)
115109

110+
monkeypatch.setenv('HOME', str(tmp_path))
116111
return _run_reframe
117112

118113

0 commit comments

Comments
 (0)