-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add reporting for copy action * Action reporter * Add summary method * Update action handlers to use reporter * Passing tests * Add CLI integration tests * Use shasum * Fix optional reporter * Configurable log level * Add integrationTests README * Add copy test * Add test for console log level * Update summary -> printSummary * Allow configuring of log level from the command line * Add configure loglevel integration test
- Loading branch information
Showing
38 changed files
with
12,337 additions
and
157 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
output/ | ||
|
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# CLI Integration Tests | ||
|
||
These tests run the CLI and ensure that a CLI command on an "input" directory | ||
results in an "output" directory that perfectly matches the "expected" | ||
directory. | ||
|
||
More thorough testing of actions should be done in unit tests. This is just | ||
another layer of assurance that the CLI is not broken when you make changes. | ||
|
||
## Run All Tests | ||
|
||
To run the tests: | ||
|
||
```sh | ||
./runTests.sh | ||
``` | ||
|
||
This does the following: | ||
|
||
- Builds the latest Bluehawk executable | ||
- Runs all "test.sh" files found in subdirectories | ||
- Checksum-compares the contents of each test's "output" and "expected" directories | ||
|
||
## Run a Specific Test | ||
|
||
The "runTests.sh" script optionally takes one argument. This can be the | ||
directory name that contains a test.sh file. | ||
|
||
The following example will only run the "snip" test: | ||
|
||
```sh | ||
./runTests.sh snip | ||
``` | ||
|
||
## Add a Test | ||
|
||
To create a test, copy an existing test as a template: | ||
|
||
```sh | ||
cp -R ./snip myNewTest | ||
``` | ||
|
||
Within your new test directory, create input files (if needed) in a directory | ||
called "input". | ||
|
||
Create the expected result file(s) and place them in a directory called | ||
"expected". | ||
|
||
Update the command in "myNewTest/test.sh" to the command you want to test. The | ||
`$BLUEHAWK` environment variable will be set to the current development build. | ||
|
||
Ensure the output of your command is sent to a directory called "output". | ||
|
||
Use the parent directory's "runTests.sh" script to run your test. |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Hi, this is a sample text. | ||
|
||
This text should be in state1 | ||
|
||
That's all, folks! | ||
|
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Hi, this is a sample text. | ||
|
||
This text should be in state2 | ||
|
||
That's all, folks! | ||
|
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Hi, this is a sample text. | ||
|
||
:state-start: state1 | ||
This text should be in state1 | ||
:state-end: | ||
:state-start: state2 | ||
This text should be in state2 | ||
:state-end: | ||
|
||
That's all, folks! | ||
|
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash -e | ||
|
||
cd "$(dirname "$0")" | ||
|
||
rm -rf output | ||
mkdir output | ||
|
||
$BLUEHAWK copy --state state1 -d ./output/state1 input | ||
$BLUEHAWK copy --state state2 -d ./output/state2 input |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Processed 3 files: | ||
- 0 binary files | ||
- 3 text files | ||
- 2 errors | ||
- 0 files written |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
bluehawk errors on path/to/project/input/sample.txt: | ||
(parser) Line 11:1 - 11:1(162) blockTag: After Newline, expected TagEnd but found EOF | ||
bluehawk errors on path/to/project/input/sample.txt: | ||
(parser) Line 11:1 - 11:1(162) blockTag: After Newline, expected TagEnd but found EOF | ||
Processed 3 files: | ||
- 0 binary files | ||
- 3 text files | ||
- 2 errors | ||
- 0 files written |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
bluehawk errors on path/to/project/input/sample.txt: | ||
(parser) Line 11:1 - 11:1(162) blockTag: After Newline, expected TagEnd but found EOF | ||
bluehawk errors on path/to/project/input/sample.txt: | ||
(parser) Line 11:1 - 11:1(162) blockTag: After Newline, expected TagEnd but found EOF | ||
state not found: notfound | ||
Processed 3 files: | ||
- 0 binary files | ||
- 3 text files | ||
- 2 errors | ||
- 0 files written |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
parsed file: path/to/project/input/normalFile.txt | ||
bluehawk errors on path/to/project/input/sample.txt: | ||
(parser) Line 11:1 - 11:1(162) blockTag: After Newline, expected TagEnd but found EOF | ||
bluehawk errors on path/to/project/input/sample.txt: | ||
(parser) Line 11:1 - 11:1(162) blockTag: After Newline, expected TagEnd but found EOF | ||
state not found: notfound | ||
Processed 3 files: | ||
- 0 binary files | ||
- 3 text files | ||
- 2 errors | ||
- 0 files written |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Hi, this is a sample text. | ||
|
||
|
||
|
||
:snippet-start: test-one | ||
This text should be in test-one | ||
|
||
Yes I forgot to close this snippet to force an error. | ||
|
||
That's all, folks! | ||
|
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash -e | ||
|
||
cd "$(dirname "$0")" | ||
|
||
rm -rf output | ||
mkdir output | ||
|
||
# These are meant to cause errors, so don't fail out the script. | ||
set +e | ||
|
||
for LOGLEVEL in 0 1 2 3 | ||
do | ||
# - Ignore the actual output, just look at the logs | ||
# - Use a state that is not actually found to trigger the state not found warning | ||
# - Set the log level to each possible level | ||
# - Redirect stderr to stdout | ||
# - Pipe to sed, delete any instances of your computer name | ||
# - Pipe to a file | ||
$BLUEHAWK snip -d output/ignoreThis --state notfound --logLevel $LOGLEVEL input 2>&1 | sed -e "s!$(pwd)!path/to/project!g" > output/logLevel$LOGLEVEL | ||
done | ||
set -e |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash -e | ||
|
||
# Local build setup | ||
pushd "$(dirname "$0")" > /dev/null | ||
pushd .. > /dev/null | ||
PROJECT_ROOT="`pwd`" | ||
npm install | ||
npm run build | ||
popd > /dev/null | ||
export BLUEHAWK="node $PROJECT_ROOT/build/src/main" | ||
|
||
function checksum() { | ||
pushd "$1" > /dev/null | ||
CHECKSUM_RESULT=`find . -type f ! -name ".DS_Store" -exec shasum {} + | sort | shasum` | ||
popd > /dev/null | ||
} | ||
|
||
# Select tests | ||
if [ -z "$1" ] | ||
then | ||
TESTS=`find . -name "test.sh"` | ||
else | ||
TESTS="$1"/test.sh | ||
fi | ||
|
||
# Run tests | ||
for TEST in $TESTS | ||
do | ||
TEST_DIR="$(dirname "$TEST")" | ||
"$TEST" | ||
checksum ./"$TEST_DIR"/expected | ||
EXPECTED_CHECKSUM=$CHECKSUM_RESULT | ||
checksum ./"$TEST_DIR"/output | ||
OUTPUT_CHECKSUM=$CHECKSUM_RESULT | ||
if [ "$EXPECTED_CHECKSUM" != "$OUTPUT_CHECKSUM" ] | ||
then | ||
echo "Test failed: $TEST_DIR" | ||
echo "Compare ./$TEST_DIR/expected and ./$TEST_DIR/output to debug." | ||
exit 1 | ||
else | ||
echo "✅ Test passed: $TEST_DIR" | ||
fi | ||
done |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
This text should be in test-one |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Hi, this is a sample text. | ||
|
||
:snippet-start: test-one | ||
This text should be in test-one | ||
:snippet-end: | ||
|
||
That's all, folks! | ||
|
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash -e | ||
|
||
cd "$(dirname "$0")" | ||
|
||
rm -rf output | ||
mkdir output | ||
|
||
$BLUEHAWK snip -d ./output input |
Oops, something went wrong.