This repository was archived by the owner on Jan 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,24 @@ | ||
from subprocess import check_call, check_output | ||
|
||
from . process import find_executable | ||
|
||
|
||
class SpackCmd: | ||
@property | ||
def spack(self): | ||
return find_executable('spack', required=False) | ||
|
||
def install(self, *args): | ||
self.cmd('install', '--show-log-on-error', '--verbose', *args) | ||
|
||
def install_dir(self, *args): | ||
output = self.cmd('location', '--install-dir', *args, output=True) | ||
return output.strip().decode('utf-8') | ||
|
||
def cmd(self, *args, **kwargs): | ||
command = [self.spack] + list(args) | ||
if kwargs.get('output', False): | ||
func = check_output | ||
else: | ||
func = check_call | ||
return func(command) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,53 @@ | ||
import mock | ||
import os | ||
import os.path as osp | ||
import shutil | ||
import sys | ||
import unittest | ||
|
||
from hpcbench.campaign import ReportNode | ||
from . import DriverTestCase | ||
|
||
|
||
FOO_INSTALL_DIR = DriverTestCase.mkdtemp() | ||
|
||
|
||
def co_mock(command): | ||
if command[1:4] == ['location', '--install-dir', 'foo@dev']: | ||
return (FOO_INSTALL_DIR + '\n').encode() | ||
raise NotImplementedError | ||
|
||
|
||
def cc_mock(command): | ||
if command[1] == 'install' and command[-1] == 'foo@dev': | ||
return | ||
with open('/tmp/foo.txt', 'w') as ostr: | ||
ostr.write(repr(command)) | ||
raise NotImplementedError | ||
|
||
|
||
CO_MOCK = mock.Mock(side_effect=co_mock) | ||
CC_MOCK = mock.Mock(side_effect=cc_mock) | ||
|
||
|
||
class TestSpack(DriverTestCase, unittest.TestCase): | ||
@classmethod | ||
@mock.patch('hpcbench.toolbox.spack.check_output', new=CO_MOCK) | ||
@mock.patch('hpcbench.toolbox.spack.check_call', new=CC_MOCK) | ||
def setUpClass(cls): | ||
# prepare spack install directory of 'foo' package | ||
bin_dir = osp.join(FOO_INSTALL_DIR, 'bin') | ||
foo_python = osp.join(bin_dir, 'foo-python') | ||
os.mkdir(bin_dir) | ||
os.symlink(sys.executable, foo_python) | ||
super(cls, cls).setUpClass() | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
shutil.rmtree(FOO_INSTALL_DIR) | ||
super(cls, cls).tearDownClass() | ||
|
||
def test(self): | ||
report = ReportNode(self.CAMPAIGN_PATH) | ||
data = list(report.collect('command_succeeded')) | ||
self.assertEqual(data, [True] * 3) |
This file contains hidden or 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,7 @@ | ||
benchmarks: | ||
'*': | ||
bench-name: | ||
type: fake | ||
spack: {specs: [foo@dev]} | ||
attributes: | ||
executable: foo-python |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned also in the other repo. do we really need this additional level. It seems redundant, or do you think in the future we might have other spack functions that would go in there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the feedback. I agree this extra level is a pain, but as I am not expert at spack, I prefered to leave space for future changes.