-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test wildcards #98
Open
forsyth2
wants to merge
1
commit into
E3SM-Project:main
Choose a base branch
from
forsyth2:test-wildcards
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Test wildcards #98
Changes from all commits
Commits
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 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 |
---|---|---|
|
@@ -10,12 +10,12 @@ class TestExtract(TestZstash): | |
""" | ||
# `zstash extract` is tested in TestExtract and TestExtractParallel. | ||
# x = on, no mark = off, b = both on and off tested | ||
# option | ExtractVerbose | ExtractKeep | ExtractCache | ExtractParallel | | ||
# --hpss |x|x|x|x| | ||
# --workers | | | |x| | ||
# --cache | | |x| | | ||
# --keep | |x| | | | ||
# -v |x| | |b| | ||
# option | ExtractVerbose | ExtractKeep | ExtractCache | ExtractWildcard | ExtractParallel | | ||
# --hpss |x|x|x|x|x| | ||
# --workers | | | | |x| | ||
# --cache | | |x| | | | ||
# --keep | |x| | | | | ||
# -v |x| | | |b| | ||
|
||
def helperExtractVerbose(self, test_name, hpss_path, zstash_path=ZSTASH_PATH): | ||
""" | ||
|
@@ -98,7 +98,7 @@ def helperExtractKeep(self, test_name, hpss_path, zstash_path=ZSTASH_PATH): | |
if not compare(os.listdir(self.cache), | ||
['index.db', '000000.tar', '000001.tar', '000002.tar', '000003.tar', '000004.tar']): | ||
error_message = 'The zstash directory does not contain expected files.\nIt has: {}'.format( | ||
os.listdir(d)) | ||
os.listdir(self.cache)) | ||
self.stop(error_message) | ||
os.chdir(TOP_LEVEL) | ||
expected_present = ['Extracting file0.txt', 'Extracting file0_hard.txt', 'Extracting file0_soft.txt', | ||
|
@@ -131,6 +131,45 @@ def helperExtractCache(self, test_name, hpss_path, zstash_path=ZSTASH_PATH): | |
error_message = 'The zstash cache does not contain expected files.\nIt has: {}'.format(files) | ||
self.stop(error_message) | ||
|
||
def helperExtractWildcard(self, test_name, hpss_path, zstash_path=ZSTASH_PATH): | ||
""" | ||
Test `zstash extract` with wildcard. | ||
""" | ||
self.assertWorkspace() | ||
print_in_box(test_name) | ||
self.hpss_path = hpss_path | ||
if self.hpss_path.lower() == 'none': | ||
use_hpss = False | ||
else: | ||
use_hpss = True | ||
os.mkdir(self.test_dir) | ||
os.chdir(self.test_dir) | ||
write_file('aa0.txt', 'aa0') | ||
write_file('aa1.txt', 'aa1') | ||
write_file('ab2.txt', 'ab2') | ||
write_file('ab3.txt', 'ab3') | ||
os.chdir(TOP_LEVEL) | ||
self.create(use_hpss, zstash_path) | ||
# Rename test_dir to backup_dir so that the new test_dir won't have the files we're trying to extract. | ||
os.rename(self.test_dir, self.backup_dir) | ||
os.mkdir(self.test_dir) | ||
os.chdir(self.test_dir) | ||
if not use_hpss: | ||
shutil.copytree('{}/{}/{}'.format(TOP_LEVEL, self.backup_dir, self.cache), self.copy_dir) | ||
cmd = '{}zstash extract --hpss={} ab*'.format(zstash_path, self.hpss_path) | ||
output, err = run_cmd(cmd) | ||
print(output + err) | ||
expected_present = ['Extracting ab2.txt', 'Extracting ab3.txt'] | ||
self.check_strings(cmd, output + err, expected_present, []) | ||
cmd = '{}zstash extract --hpss={} a*'.format(zstash_path, self.hpss_path) | ||
output, err = run_cmd(cmd) | ||
print(output + err) | ||
expected_present = ['Extracting aa0.txt', 'Extracting aa1.txt', | ||
'Not extracting ab2.txt', 'Not extracting ab3.txt'] | ||
self.check_strings(cmd, output + err, expected_present, []) | ||
os.chdir(TOP_LEVEL) | ||
|
||
|
||
def testExtractVerbose(self): | ||
self.helperExtractVerbose('testExtractVerbose', 'none') | ||
|
||
|
@@ -148,6 +187,9 @@ def testExtractKeepHPSS(self): | |
def testExtractCache(self): | ||
self.helperExtractCache('testExtractCache', 'none') | ||
|
||
def testExtractWildcard(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need a test with HPSS too? |
||
self.helperExtractWildcard('testExtractWildcard', 'none') | ||
|
||
def testExtractCacheHPSS(self): | ||
self.conditional_hpss_skip() | ||
self.helperExtractCache('testExtractCacheHPSS', HPSS_ARCHIVE) | ||
|
This file contains 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.
Interestingly, adding double quotes seems to cause a failure and not adding them allows the tests to pass -- the reverse of our experience as users. I believe this is because
subprocess.Popen
requirescmd
to be converted to a list and I imagine the conversion encapsulatesa*
in quotes. Not sure if there's a way to automate a test in such a way as to use the quotes.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.
Try using
shell=True
? If that doesn't work, perhaps we should just close #96 without adding automated testing.