Skip to content

Commit f13450d

Browse files
committed
Implement pgxn_meta CLI
Keep it simple right now, mimicking [validate_pgxn_meta], although the `--man` option currently doesn't do much. Use lexopt for argument parsing, since it's super simple like this use case. Avoid [std::process::exit] and set a boolean to return [std::process::ExitCode] when the app should exit without processing a file. This makes it easier to test things, since the functions to print the usage statement or version don't exit. Include tests that cover every bit of functionality, including the `main()` function. Add `corpus/invalid.json` to properly test validation failure. Try to improve the coveralls formatting. [validate_pgxn_meta]: https://metacpan.org/pod/validate_pgxn_meta [std::process::exit]: https://doc.rust-lang.org/stable/std/process/fn.exit.html [std::process::ExitCode]: https://doc.rust-lang.org/stable/std/process/struct.ExitCode.html
1 parent 58ffb17 commit f13450d

File tree

6 files changed

+357
-6
lines changed

6 files changed

+357
-6
lines changed

.ci/test-cover

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ grcov "${DESTDIR}" \
2323
-s . \
2424
--branch \
2525
-o "${DESTDIR}" \
26-
--output-types html,cobertura
27-
28-
xmllint --xpath "concat('Coverage: ', 100 * string(//coverage/@line-rate), '%')" "${DESTDIR}/cobertura.xml"
26+
--token 5DOLLPIHEO \
27+
--output-types html,coveralls
2928

3029
if [ "$(uname -o)" = "Darwin" ] && [ -z "$CI" ]; then
3130
open "${DESTDIR}/html/index.html"

.github/workflows/test-and-lint.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,11 @@ jobs:
3333
uses: dtolnay/rust-toolchain@stable
3434
- name: Run pre-commit
3535
uses: pre-commit/[email protected]
36-
- name: Install dependencies
37-
run: sudo apt-get install -y libxml2-utils
3836
- name: Generate Coverage
3937
run: make cover RUST_BACKTRACE=1
4038
- name: Publish Coverage
4139
uses: codecov/codecov-action@v4
4240
with:
4341
token: ${{ secrets.CODECOV_TOKEN }}
4442
slug: pgxn/meta
45-
files: target/cover/cobertura.xml
43+
files: target/cover/coveralls

Cargo.lock

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ exclude = [ ".github", ".gitattributes", "target", ".vscode", ".gitignore" ]
1414

1515
[dependencies]
1616
boon = "0.6"
17+
lexopt = "0.3.0"
1718
relative-path = "1.9.3"
1819
serde = { version = "1", features = ["derive"] }
1920
serde_json = "1.0"

corpus/invalid.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "pair",
3+
"abstract": "A key/value pair data type",
4+
"maintainers": [
5+
{
6+
"name": "David E. Wheeler",
7+
"email": "[email protected]"
8+
}
9+
],
10+
"license": "PostgreSQL",
11+
"contents": {
12+
"extensions": {
13+
"pair": {
14+
"sql": "sql/pair.sql",
15+
"control": "pair.control"
16+
}
17+
}
18+
},
19+
"meta-spec": { "version": "2.0.0" }
20+
}

0 commit comments

Comments
 (0)