-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Review of failed tests logic and Integration Tests (#5)
* Introduced MojoTest without changes to the plugin * Added test pipeline * Added exports to the Test step * Fixed bash code * Checking now for exception or TEST_FAILED_PREFIX in stdout. * Added Integration tests for warnings * Updating version for testing * Moving back the return code to 0. * Removed raises and updated docstring. * Moving warning return code back to 1 * Updated README.md
- Loading branch information
Showing
10 changed files
with
92 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Run Tests | ||
|
||
on: ["push"] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v2 | ||
- name: Install dependencies | ||
run: | | ||
curl https://get.modular.com | MODULAR_AUTH=${{ secrets.MODULAR_AUTH }} sh - | ||
modular auth ${{ secrets.MODULAR_AUTH }} | ||
modular install mojo | ||
pip install . | ||
- name: Integration Tests | ||
run: | | ||
export MODULAR_HOME="/home/runner/.modular" | ||
export PATH="/home/runner/.modular/pkg/packages.modular.com_mojo/bin:$PATH" | ||
# Tests that do not fail | ||
pytest example/tests/mod_b | ||
# Tests that should fail | ||
if pytest example/tests/mod_a ; then | ||
echo "This tests should fail" | ||
exit 1 | ||
fi | ||
# Test should fail becuase I am passing options for checking warnings | ||
rm -rf ~/.modular/.mojo_cache | ||
if pytest -W error example/tests/test_warning.mojo ; then | ||
echo "This tests should fail" | ||
exit 1 | ||
fi | ||
# Test should not fail becuase I am not checking for warning | ||
rm -rf ~/.modular/.mojo_cache | ||
pytest example/tests/test_warning.mojo | ||
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
from example.mod_a.impl import maths, convert, convert_different | ||
from example.tests.util import assert_true | ||
from example.tests.util import MojoTest | ||
|
||
|
||
fn main() raises: | ||
test_convert() | ||
|
||
|
||
fn test_convert() raises: | ||
print("# convert") | ||
let test = MojoTest("convert") | ||
let x: Int = 42 | ||
let expect = SIMD[DType.float64](42) | ||
let result = convert(x) | ||
assert_true(result == expect, "convert unexpected result: " + String(result)) | ||
test.assert_true(result == expect, "convert unexpected result: " + String(result)) |
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
from example.mod_a.impl import maths, convert_different | ||
from example.tests.util import assert_true | ||
from example.tests.util import MojoTest | ||
|
||
|
||
fn main() raises: | ||
test_convert_different() | ||
|
||
|
||
fn test_convert_different() raises: | ||
print("# convert_different") | ||
let test = MojoTest("convert_different") | ||
let x: Int = 8 | ||
let expect = SIMD[DType.float16](8) | ||
let result = convert_different(x) | ||
assert_true(result == expect, "convert unexpected result: " + String(result)) | ||
test.assert_true(result == expect, "convert unexpected result: " + String(result)) |
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
from example.mod_b.impl import greet | ||
from example.tests.util import assert_true | ||
from example.tests.util import MojoTest | ||
|
||
|
||
fn main() raises: | ||
test_greet() | ||
|
||
|
||
fn test_greet() raises: | ||
print("# greet result") | ||
let test = MojoTest("greet result") | ||
let result = greet("guido") | ||
let expect = "Hey guido" | ||
assert_true(result == expect, "greet unexpected result: " + String(result)) | ||
test.assert_true(result == expect, "greet unexpected result: " + String(result)) |
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 |
---|---|---|
@@ -1,9 +1,20 @@ | ||
import testing | ||
|
||
|
||
fn assert_true(cond: Bool, message: String) raises: | ||
@value | ||
struct MojoTest: | ||
""" | ||
Wraps testing.assert_true, raises Error on assertion failure. | ||
A utility struct for testing. | ||
""" | ||
if not testing.assert_true(cond, message): | ||
raise Error(message) | ||
|
||
var test_name: String | ||
|
||
fn __init__(inout self, test_name: String): | ||
self.test_name = test_name | ||
print("# " + test_name) | ||
|
||
fn assert_true(self, cond: Bool, message: String): | ||
""" | ||
Wraps testing.assert_true. | ||
""" | ||
_ = testing.assert_true(cond, message) |
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