Skip to content

Commit c699eab

Browse files
authored
Adds a progress indication (#44)
The progress indication is a manually regenerated file, which is simplistic but gets the job done. With an appropriate environment set up, one: ```bash make cov ``` will generate a coverage report into /coverage/report.md Fixes #30
1 parent 8e7f9ca commit c699eab

18 files changed

+700
-5
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,6 @@ uprev:
101101
$(call uprev,rust_icu_ucal)
102102
$(call uprev,rust_icu_udat)
103103
$(call uprev,rust_icu_udata)
104+
105+
cov:
106+
./build/showprogress.sh

README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
| ICU 64/65/66 | [![Build Status `master`](https://travis-ci.org/google/rust_icu.svg?branch=master)](https://travis-ci.org/google/rust_icu) |
66
| Source | https://github.com/google/rust_icu |
77
| README | https://github.com/google/rust_icu/blob/master/README.md |
8+
| Coverage | [View report](/coverage/report.md)
89

910
This is a library of low level native rust language bindings for the
1011
International Components for Unicode (ICU) library for C (a.k.a. ICU4C).
@@ -39,6 +40,9 @@ example, `rust_icu_uenum` implements the functionality that one would find in
3940
the [uenum.h](http://www.icu-project.org/apiref/icu4c/uenum_8h.html) header
4041
file.
4142

43+
Please consult the [coverage report](/coverage/report.md) for details about
44+
function coverage in the headers given above.
45+
4246
| Crate | Description |
4347
| ----- | ----------- |
4448
| [rust_icu_sys](https://crates.io/crates/rust_icu_sys)| Low-level bindings code |
@@ -51,11 +55,6 @@ file.
5155
| [rust_icu_ustring](https://crates.io/crates/rust_icu_ustring)| Implements `ustring.h` C API header from the ICU library. |
5256
| [rust_icu_utext](https://crates.io/crates/rust_icu_utext)| Implements `utext.h` C API header from the ICU library. |
5357

54-
At the moment, all implementations are very partial. There is currently no
55-
registry of the API coverage, which makes things a bit difficult to follow.
56-
57-
The goal is to correct this situation and have a comprehensive coverage matrix.
58-
5958
# Limitations
6059

6160
The generated rust language binding methods of today limit the availability of

build/showprogress.sh

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Generates an ICU feature coverage support report.
5+
6+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
7+
TOP_DIR="${TOP_DIR:-${DIR}/..}"
8+
cd $TOP_DIR
9+
10+
C_API_HEADER_NAMES=(
11+
"ustring"
12+
"ucal"
13+
"udat"
14+
"udata"
15+
"uenum"
16+
"uloc"
17+
"ustring"
18+
"utext"
19+
)
20+
21+
ICU_INCLUDE_PATH="$(icu-config --cppflags-searchpath | sed -e 's/-I//' | sed -e 's/ //g')"
22+
23+
for header_basename in ${C_API_HEADER_NAMES[@]}; do
24+
header_fullname="${ICU_INCLUDE_PATH}/unicode/${header_basename}.h"
25+
echo $header_basename: $header_fullname
26+
ctags -x --c-kinds=fp $header_fullname | sed -e 's/\s.*$//' \
27+
| grep -v U_DEFINE | sort | uniq \
28+
> "${TOP_DIR}/coverage/${header_basename}_all.txt"
29+
30+
# Extracts all mentions of functions such as "utext_close" for example from
31+
# rust docs of the form "/// Implements `utext_close` ... ". This is
32+
# simplistic but quite enough with a little bit of care.
33+
find . -path "*rust_icu_${header_basename}/src/*.rs" | \
34+
xargs grep "/// Implements \`" | sed -e 's/.*`\(.*\)`.*$/\1/' | \
35+
sort | uniq > "${TOP_DIR}/coverage/${header_basename}_implemented.txt"
36+
done
37+
38+
# Now, write a report out. Again, simplistic, but gets the job done.
39+
40+
REPORT_FILE="${TOP_DIR}/coverage/report.md"
41+
cat <<EOF > "${REPORT_FILE}"
42+
# Implementation coverage report
43+
44+
| Header | Implemented |
45+
| ------ | ----------- |
46+
EOF
47+
for header_basename in ${C_API_HEADER_NAMES[@]}; do
48+
total_functions="$(cat "${TOP_DIR}"/coverage/${header_basename}_all.txt | wc -l)"
49+
implemented_functions="$(cat "${TOP_DIR}"/coverage/${header_basename}_implemented.txt | wc -l)"
50+
echo "| \`${header_basename}.h\` | ${implemented_functions} / ${total_functions} | " >> "${REPORT_FILE}"
51+
done
52+
53+
cat <<EOF >>"${REPORT_FILE}"
54+
# Unimplemented functions per header
55+
56+
EOF
57+
for header_basename in ${C_API_HEADER_NAMES[@]}; do
58+
cat <<EOF >>"${REPORT_FILE}"
59+
60+
# Header: \`${header_basename}.h\`
61+
62+
| Unimplemented | Implemented |
63+
| ------------- | ----------- |
64+
EOF
65+
for fun in $(cat "${TOP_DIR}/coverage/${header_basename}_implemented.txt"); do
66+
echo "| | \`${fun}\` |" >>"${REPORT_FILE}"
67+
done
68+
69+
unimplemented="$(comm -23 \
70+
"${TOP_DIR}/coverage/${header_basename}_all.txt" \
71+
"${TOP_DIR}/coverage/${header_basename}_implemented.txt" | sort | uniq)"
72+
for fun in ${unimplemented}; do
73+
echo "| \`${fun}\` | |" >>"${REPORT_FILE}"
74+
done
75+
done
76+

0 commit comments

Comments
 (0)