Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Document use of Validation section #100

Open
SorraTheOrc opened this issue Feb 23, 2018 · 6 comments
Open

Document use of Validation section #100

SorraTheOrc opened this issue Feb 23, 2018 · 6 comments

Comments

@SorraTheOrc
Copy link
Contributor

Validation sections are both a normal part of a document and a way to test if a prerequisite is run. This issue is about their use as a normal part of a document. In this mode the validation section should be run. Consider the example below which should output and/or test the value of UNIQUE_FILENAME when run in any mode.

ASIDE: I've written this example as both documentation and test script... where should it live?

How to use Environment Variables to Configure SimDem Scripts

It can be convenient to have a SimDem script that creates a number of environment variables for use in other scripts. This script can then be used as a prerequisite to ensure that you have a consistent environment on each execution. To set an environment variable use a command like the following:

MY_VARIABLE="My value"

You can use bash commands to create unique strings too:

UNIQUE_FILENAME=my_filename_$(date +%Y-%m-%d-%H)

If you want to avoid overwriting values provided by the SimDem user, you can easily do so with a value check:

if [ -z "$ANOTHER_UNIQUE_FILENAME" ]; then $ANOTHER_UNIQUE_FILENAME = my_filename_$(date +%Y-%m-%d-%H); fi

Validation

A validation section is useful in two ways. It can be used to ensure we output the final results when executing in a tutorial/demo environment and it can be used to test whether a prerequisite file needs to be run. For example:

if [ -z "$UNIQUE_FILENAME" ]; echo "We need to provide or generate a unique filename"; else "UNIQUE_FILENAME=$UNIQUE_FILENAME"; fi

Results:

UNIQUE_FILENAME=my_filename_yyyy-mm-dd-hh
@lastcoolnameleft
Copy link
Contributor

To answer your aside question: I've put all examples here. We can change it later, but for now it works. https://github.com/Azure/simdem/tree/simdem2/examples

Regarding implementing validation:

  • What modes do you expect validation to be implemented?
  • What is the expected behavior if validation passes?
    • Is the expected behavior different per mode?
  • What is the expected behavior if validation fails?
    • Is the expected behavior different per mode?

@SorraTheOrc
Copy link
Contributor Author

SorraTheOrc commented Mar 4, 2018 via email

@lastcoolnameleft
Copy link
Contributor

Ah, ok. I was thinking that Validation is a section that validates the entire document completed successfully.

Let me mull over this change as I will probably need to pass the "mode" variable into the parser so that it only treats "# Validation" special if it's a prerequisite.

@lastcoolnameleft
Copy link
Contributor

Correction: I will need to pass "is_prerequisite" into the parser, so that it knows if it should handle the validation section. Otherwise, it should just treat it as a regular body section.

@lastcoolnameleft
Copy link
Contributor

@rgardler Can you validate it works according to spec? I've added the following commit to the simdem2 branch which should fix the issue.

c1c7f99

@SorraTheOrc
Copy link
Contributor Author

Confirmed... working as expected, thanks. Leaving this open (but dropping priority) as a reminder for me to move the example into docs.

@SorraTheOrc SorraTheOrc added P-Low and removed P-High labels Mar 6, 2018
@SorraTheOrc SorraTheOrc changed the title SimDem2: Validation section not run Document use of Validation section Mar 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants