-
Notifications
You must be signed in to change notification settings - Fork 3
Run isolation tests if there is specs folder.
#3
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,35 @@ | ||
| import os | ||
| import shlex | ||
| import shutil | ||
|
|
||
| from pkg_resources import resource_filename | ||
|
|
||
| from .config import CONFIG, TOOL_MAKE | ||
| from .exceptions import Error | ||
| from .terminal import Style | ||
| from .utils import execute, ExecOutput | ||
| from .utils import execute, ExecOutput, str_args_to_dict | ||
|
|
||
|
|
||
| class Extension: | ||
| def __init__(self, work_dir, pg_config): | ||
| self.work_dir = work_dir | ||
| self.pg_config = pg_config | ||
|
|
||
| def make(self, targets=None, options=None): | ||
| self.specs = None | ||
| specs_dir = os.path.join(work_dir, 'specs') | ||
| if os.path.exists(specs_dir): | ||
| self.specs = [os.path.splitext(spec)[0] for spec in os.listdir(specs_dir)] | ||
|
|
||
| self._regress_opts = None | ||
|
|
||
| def get_temp_config(self): | ||
|
Owner
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. This function is a perfect candidate for being a property. |
||
| mk_var = 'EXTRA_REGRESS_OPTS' | ||
| if self._regress_opts is None: | ||
| self._regress_opts = str_args_to_dict(self.makefile_var(mk_var)) | ||
|
|
||
| return self._regress_opts.get('--temp-config') | ||
|
|
||
| def make(self, targets=None, options=None, instance=None): | ||
|
|
||
| if not targets: | ||
| targets = CONFIG['pgxs']['default_targets'] | ||
|
|
@@ -50,6 +65,39 @@ def make(self, targets=None, options=None): | |
| cwd=self.work_dir, | ||
| env=os.environ, | ||
| output=ExecOutput.Stdout) | ||
|
|
||
| if target in ('check', 'installcheck') and self.specs: | ||
| print(Style.green('\n$ make isolationcheck')) | ||
|
|
||
| tmpdir = os.path.join(self.work_dir, "tmp_check_iso") | ||
|
Owner
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. Maybe we should use |
||
| if os.path.exists(tmpdir): | ||
| shutil.rmtree(tmpdir) | ||
|
|
||
| isolation_args = [ | ||
| os.path.join(instance.work_dir, | ||
| "src/test/isolation/pg_isolation_regress"), | ||
| "--temp-instance=%s" % tmpdir, | ||
|
Owner
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. Bikeshedding: I personally prefer |
||
| "--inputdir=.", | ||
| "--outputdir=output_iso", | ||
|
Owner
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. Needless contraction -- |
||
| "--bindir=%s" % instance.get_bin_path(""), | ||
| ] | ||
|
|
||
| temp_config = self.get_temp_config() | ||
| if temp_config: | ||
| isolation_args.append("--temp-config=%s" % temp_config) | ||
|
|
||
| for spec in self.specs: | ||
| isolation_args.append(spec) | ||
|
|
||
| try: | ||
| execute(isolation_args, | ||
| cwd=self.work_dir, | ||
| env=os.environ, | ||
| output=ExecOutput.Stdout) | ||
| finally: | ||
| if os.path.exists(tmpdir): | ||
| shutil.rmtree(tmpdir) | ||
|
|
||
| print() | ||
|
|
||
| def makefile_var(self, name): | ||
|
|
||
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.
We probably shouldn't hardwire
specsdir name. Maybe we could add a default-able flag to thepgxscommand?