зеркало из https://github.com/Azure/simdem.git
More efficient and reliable tracking of prerequisites. (#67)
* ensure we are correctly tracking prereq and other sections (note this wasn't a problem before, adding merely to catch unexpected edge cases) * if prereq step is empty record as a description line rather than a prereq * we must have a source_file_dir, otherwise we don't know where to build relative paths from * typo * more descriptive comment * incorrect timeout option for curl, tests were passing but there was an extra attempt to connect to a url of '-connect-timeout' * Add a check for whether a prereq has already been run or not. This will make execution faster when a prereq comes from two different parts of a test plan (for example) * simpler way of tracking prereq validation - which happens to work too! * Merge from master
This commit is contained in:
Родитель
6ea901dbcf
Коммит
e9e1c19f59
4
cli.py
4
cli.py
|
@ -300,7 +300,7 @@ to select it) and a title (to be displayed).
|
|||
if command.startswith("xdg-open "):
|
||||
self.warning("Since you are running in headless CLI mode it is not possible to execute xdg-open commands.")
|
||||
|
||||
command = "curl -I " + command[9:] + " -connect-timeout 90"
|
||||
command = "curl -I " + command[9:] + " --connect-timeout 90"
|
||||
|
||||
self.warning("Converting to `" + command + "`")
|
||||
self.warning("Note that this may break tests.")
|
||||
|
@ -319,7 +319,7 @@ to select it) and a title (to be displayed).
|
|||
|
||||
def expand_vars(self, command):
|
||||
"""Expand the variables in the supplied command by replacing them
|
||||
with the value they carry in the Environment."""
|
||||
with the value they carry in the Environment. This is used by some special commands because the shell doesn't expand them (e.g. copying a $URL into a browser window using xdg-open)"""
|
||||
|
||||
self.log("debug", "Expanding vars in " + command)
|
||||
var_pattern = re.compile(".*?(?<=\$)\(?{?(\w*)(?=[\W|\$|\s|\\\"]?)\)?(?!\$).*")
|
||||
|
|
24
demo.py
24
demo.py
|
@ -55,7 +55,8 @@ class Demo(object):
|
|||
self.is_prerequisite = is_prerequisite
|
||||
self.output_format = output_format
|
||||
self.all_results = []
|
||||
|
||||
self.completed_validation_steps = []
|
||||
|
||||
def set_script_dir(self, script_dir, base_dir = None):
|
||||
if base_dir is not None and not base_dir.endswith(os.sep):
|
||||
base_dir += os.sep
|
||||
|
@ -498,7 +499,7 @@ logs throughout execution."""
|
|||
actual_results = ""
|
||||
failed_tests = 0
|
||||
passed_tests = 0
|
||||
in_prerequisites = False
|
||||
done_prerequisites = False
|
||||
in_validation = False
|
||||
executed_code_in_this_section = False
|
||||
next_steps = []
|
||||
|
@ -531,16 +532,12 @@ logs throughout execution."""
|
|||
expected_results = ""
|
||||
actual_results = ""
|
||||
in_results = False
|
||||
elif line["type"] == "prerequisite" and not in_prerequisites:
|
||||
self.ui.log("debug", "Entering prerequisites")
|
||||
in_prerequisites = True
|
||||
elif line["type"] != "prerequisites" and len(line["text"]) > 0 and in_prerequisites:
|
||||
self.ui.log("debug", "Got all prerequisites")
|
||||
elif line["type"] == "prerequisite" and not done_prerequisites:
|
||||
self.ui.heading(line["text"])
|
||||
self.check_prerequisites(lines, source_file_directory)
|
||||
done_prerequisites = True
|
||||
if self.is_prep_only:
|
||||
return failed_tests, passed_tests
|
||||
in_prerequisites = False
|
||||
self.ui.heading(line["text"])
|
||||
elif line["type"] == "executable":
|
||||
if line["text"].strip() == "":
|
||||
break
|
||||
|
@ -610,6 +607,7 @@ logs throughout execution."""
|
|||
href = href + "README.md"
|
||||
step["href"] = href
|
||||
steps.append(step)
|
||||
self.ui.log("debug", "Found prereq: " + str(step))
|
||||
|
||||
for step in steps:
|
||||
path, filename = os.path.split(step["href"])
|
||||
|
@ -622,6 +620,12 @@ logs throughout execution."""
|
|||
else:
|
||||
new_dir = path
|
||||
|
||||
new_dir = os.path.abspath(new_dir)
|
||||
full_path = os.path.join(new_dir, filename)
|
||||
if full_path in self.completed_validation_steps:
|
||||
self.ui.log("debug", "Already validated / executed script in " + full_path)
|
||||
return
|
||||
|
||||
self.ui.new_para()
|
||||
|
||||
self.ui.log("debug", "Execute prerequisite step in " + filename + " in " + new_dir)
|
||||
|
@ -631,6 +635,8 @@ logs throughout execution."""
|
|||
demo.run_if_validation_fails(self.mode)
|
||||
self.ui.get_shell().run_command("popd ") # set_ui runs pushd
|
||||
self.ui.set_demo(self) # demo.set_ui(...) assigns new demo to ui, this reverts after prereq execution
|
||||
|
||||
self.completed_validation_steps.append(full_path)
|
||||
self.ui.check_for_interactive_command()
|
||||
|
||||
def run_if_validation_fails(self, mode = None):
|
||||
|
|
|
@ -37,6 +37,11 @@ test files. The [prerequisite test script](./prerequisites/README.md)
|
|||
validates whether the file exists and, if it doesn't it will execute
|
||||
and create it.
|
||||
|
||||
Each [prerequisite](./prerequisites/README.md) will only be run once,
|
||||
so even though this partucular prereq appears twice it will only
|
||||
execute once. This is important when building multi-part tutorials/
|
||||
demos where a prereq may be included in more than one part.
|
||||
|
||||
## Validate prerequisite ran
|
||||
|
||||
The prerequisite script should have run and created a `prereq_ran`
|
||||
|
|
|
@ -116,7 +116,7 @@ class Environment(object):
|
|||
|
||||
def process_env(self, new_env):
|
||||
"""
|
||||
Takes an environmetn definition and processes it for use.
|
||||
Takes an environment definition and processes it for use.
|
||||
For example, expand '~' to home directory.
|
||||
"""
|
||||
for key in new_env:
|
||||
|
|
Загрузка…
Ссылка в новой задаче