-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add initial readme and generation scripts (#20)
Change-Id: I0e236fede5a2f0c3ef4e31fa85ce668f4b34004a
- Loading branch information
Showing
9 changed files
with
235 additions
and
0 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,56 @@ | ||
# skytest | ||
|
||
A non-allocating[^1] C++17+ unit test framework. | ||
|
||
## overview | ||
|
||
A minimal unit test example | ||
|
||
```cpp:example/minimal_pass.cpp | ||
#include "skytest/skytest.hpp" | ||
|
||
auto main() -> int | ||
{ | ||
using namespace skytest::literals; | ||
using ::skytest::expect; | ||
|
||
"truthy"_test = [] { return expect(true); }; | ||
} | ||
|
||
``` | ||
|
||
when run, will print | ||
|
||
```console:example/minimal_pass.log | ||
test `truthy`...[32m[CONSTEXPR PASS][0m | ||
[32mall tests passed[0m (1 test) | ||
``` | ||
|
||
A test that fails | ||
|
||
```cpp:example/minimal_fail.cpp | ||
#include "skytest/skytest.hpp" | ||
|
||
auto main(int argc, char*[]) -> int | ||
{ | ||
using namespace skytest::literals; | ||
using ::skytest::eq; | ||
using ::skytest::expect; | ||
|
||
"falsy"_test = [&] { return expect(eq(0, argc)); }; | ||
} | ||
|
||
``` | ||
will print | ||
```console:example/minimal_fail.log | ||
test `falsy`...[31m[FAIL][0m example/minimal_fail.cpp:9 | ||
[31m[2m(0 == 1)[0m | ||
0 tests passed | [31m1 test failed[0m | ||
``` | ||
|
||
[^1]: The default printer uses `std::cout` and `skytest::aborts` calls `fork`. |
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,53 @@ | ||
load("@rules_python//python:defs.bzl", "py_binary") | ||
load("@bazel_skylib//rules:diff_test.bzl", "diff_test") | ||
load("@local_config_info//:defs.bzl", "BAZEL_WORKSPACE_ROOT") | ||
|
||
py_binary( | ||
name = "markdown-update", | ||
srcs = ["markdown-update.py"], | ||
visibility = ["//visibility:private"], | ||
deps = ["@markdown-embed-code"], | ||
) | ||
|
||
genrule( | ||
name = "gen_readme", | ||
srcs = ["README.md.tmpl"], | ||
outs = ["README.md.generated"], | ||
cmd = """ | ||
export BUILD_WORKSPACE_DIRECTORY={workspace_dir} | ||
$(execpath :markdown-update) $(rootpath :README.md.tmpl)> $@ | ||
""".format( | ||
workspace_dir = BAZEL_WORKSPACE_ROOT, | ||
), | ||
tags = ["manual"], | ||
tools = [":markdown-update"], | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
genrule( | ||
name = "readme.update_sh", | ||
srcs = ["README.md.tmpl"], | ||
outs = ["readme.update.sh"], | ||
cmd = """ | ||
set -euo pipefail | ||
echo "set -euo pipefail" > $@ | ||
echo "" >> $@ | ||
echo "cd \\$$BUILD_WORKSPACE_DIRECTORY" >> $@ | ||
echo "$(execpath :markdown-update) $(rootpath :README.md.tmpl) > README.md" >> $@ | ||
""", | ||
tags = ["manual"], | ||
tools = [":markdown-update"], | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
sh_binary( | ||
name = "readme.update", | ||
srcs = [":readme.update.sh"], | ||
) | ||
|
||
diff_test( | ||
name = "readme.check", | ||
failure_message = "To update, run:\n\nbazel run //scripts:readme.update", | ||
file1 = "//:README.md", | ||
file2 = "README.md.generated", | ||
) |
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,28 @@ | ||
# skytest | ||
|
||
A non-allocating[^1] C++17+ unit test framework. | ||
|
||
## overview | ||
|
||
A minimal unit test example | ||
|
||
|
||
```cpp:example/minimal_pass.cpp | ||
``` | ||
|
||
when run, will print | ||
|
||
```console:example/minimal_pass.log | ||
``` | ||
|
||
A test that fails | ||
|
||
```cpp:example/minimal_fail.cpp | ||
``` | ||
|
||
will print | ||
|
||
```console:example/minimal_fail.log | ||
``` | ||
|
||
[^1]: The default printer uses `std::cout` and `skytest::aborts` calls `fork`. |
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,24 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import argparse | ||
import os | ||
from pathlib import Path | ||
import sys | ||
|
||
from markdown_embed_code import get_code_emb | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="embed code into a markdown file.") | ||
parser.add_argument("filename") | ||
args = parser.parse_args() | ||
|
||
os.chdir(os.environ.get("BUILD_WORKSPACE_DIRECTORY")) | ||
|
||
with open(Path(args.filename), "r") as f: | ||
indoc = f.read() | ||
|
||
outdoc = get_code_emb()(indoc) | ||
|
||
sys.stdout.buffer.write(outdoc.encode()) | ||
|
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 @@ | ||
marko |
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 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.11 | ||
# by the following command: | ||
# | ||
# bazel run //tools:requirements.update | ||
# | ||
marko==2.0.2 \ | ||
--hash=sha256:2ebd448ac82636765db49777e735923c799a6d66c75bc4997a922bb4c12e4563 \ | ||
--hash=sha256:502df6d827139ea7265d819f4fe3664589f4774997eff758dc38bea4f52350e6 | ||
# via -r tools/requirements.in |