Skip to content

Commit

Permalink
review: use //! for directive comments
Browse files Browse the repository at this point in the history
  • Loading branch information
abrown committed Nov 22, 2024
1 parent 22815af commit 86bb7a1
Show file tree
Hide file tree
Showing 42 changed files with 53 additions and 53 deletions.
8 changes: 4 additions & 4 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ output.log # the captured printed output--only for errors
To add a test, create a new C file in [`src/misc`]:

```c
// filter.py(TARGET_TRIPLE): !wasm32-wasip2
// add-flags.py(CFLAGS): ...
// add-flags.py(LDFLAGS): ...
// add-flags.py(RUN): ...
//! filter.py(TARGET_TRIPLE): !wasm32-wasip2
//! add-flags.py(CFLAGS): ...
//! add-flags.py(LDFLAGS): ...
//! add-flags.py(RUN): ...
void main() { ... }
```
Expand Down
8 changes: 4 additions & 4 deletions test/scripts/add-flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Example:
# ```
# $ head one.c
# // add-flags.py(CFLAGS): -DFOO
# //! add-flags.py(CFLAGS): -DFOO
# $ ./add-flags.py CFLAGS one.c
# -DFOO

Expand All @@ -19,17 +19,17 @@
import logging

"""
Match a C comment like the following: `// add-flags.py: <FLAGS>`.
Match a C comment like the following: `//! add-flags.py: <FLAGS>`.
"""
PATTERN = re.compile('\\s*//\\s*add-flags\\.py\\(([^)]+)\\):\\s*(.*)')
PATTERN = re.compile('\\s*//\\!\\s*add-flags\\.py\\(([^)]+)\\):\\s*(.*)')


def find_flags(name, file):
with open(file, 'r') as f:
for lineno, line in enumerate(f, start=1):
match = PATTERN.match(line)
pos = f'[{file}:{lineno}]'
if match and match[1] == name:
pos = f'[{file}:{lineno}]'
logging.debug(f'{pos} found flags')
return match[2].strip()

Expand Down
10 changes: 5 additions & 5 deletions test/scripts/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Filter out test files that do not match a configuration variable.
#
# This script accepts a list of files as arguments and looks for a comment like
# the following in each: `// filter.py(<VARIABLE>): <EXPRESSION>`. The
# the following in each: `//! filter.py(<VARIABLE>): <EXPRESSION>`. The
# `VARIABLE` value is looked up in the environment and compared with the
# expression. An `EXPRESSION` is a comma-separated list of terms: either
# `<string>` or `!<string>`. If the `VARIABLE` value matches the expression, the
Expand All @@ -12,9 +12,9 @@
# Example:
# ```
# $ head one.c
# // filter.py(FOO): bar
# //! filter.py(FOO): bar
# $ head two.c
# // filter.py(FOO):!bar, baz
# //! filter.py(FOO):!bar, baz
# $ FOO=bar ./filter.py one.c two.c
# one.c
# $ FOO=baz ./filter.py one.c two.c
Expand Down Expand Up @@ -55,9 +55,9 @@ def matches_expression(value, expr, pos):


"""
Match a C comment like the following: `// filter.py(<VARIABLE>): <EXPRESSION>`.
Match a C comment like the following: `//! filter.py(<VARIABLE>): <EXPRESSION>`.
"""
PATTERN = re.compile('\\s*//\\s*filter\\.py\\(([^)]+)\\):\\s*(.*)')
PATTERN = re.compile('\\s*//\\!\\s*filter\\.py\\(([^)]+)\\):\\s*(.*)')


def line_matches(line, env, pos):
Expand Down
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/argv.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/argv.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/basename.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/basename.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/clocale_mbfuncs.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/clocale_mbfuncs.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/clock_gettime.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/clock_gettime.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/crypt.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/crypt.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/dirname.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/dirname.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/env.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/env.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/fnmatch.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/fnmatch.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/iconv_open.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/iconv_open.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/mbc.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/mbc.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/memstream.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/memstream.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/qsort.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/qsort.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/random.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/random.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/search_hsearch.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/search_hsearch.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/search_insque.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/search_insque.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/search_lsearch.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/search_lsearch.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/search_tsearch.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/search_tsearch.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/snprintf.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/snprintf.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/sscanf.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/sscanf.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/strftime.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/strftime.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/string.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/string.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/string_memcpy.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/string_memcpy.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/string_memmem.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/string_memmem.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/string_memset.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/string_memset.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/string_strchr.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/string_strchr.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/string_strcspn.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/string_strcspn.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/string_strstr.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/string_strstr.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/strtod.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/strtod.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/strtod_long.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/strtod_long.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/strtod_simple.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/strtod_simple.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/strtof.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/strtof.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/strtol.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/strtol.c"
4 changes: 2 additions & 2 deletions test/src/libc-test/functional/strtold.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// add-flags.py(CFLAGS): -I.
// add-flags.py(LDFLAGS): -lc-printscan-long-double
//! add-flags.py(CFLAGS): -I.
//! add-flags.py(LDFLAGS): -lc-printscan-long-double
#include "build/download/libc-test/src/functional/strtold.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/swprintf.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/swprintf.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/tgmath.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/tgmath.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/udiv.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/udiv.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/wcsstr.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/wcsstr.c"
2 changes: 1 addition & 1 deletion test/src/libc-test/functional/wcstol.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// add-flags.py(CFLAGS): -I.
//! add-flags.py(CFLAGS): -I.
#include "build/download/libc-test/src/functional/wcstol.c"
2 changes: 1 addition & 1 deletion test/src/misc/fts.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// add-flags.py(RUN): --dir fs::/
//! add-flags.py(RUN): --dir fs::/

/*
* We modified musl-fts not to use fchdir() and we made FTS_NOCHDIR
Expand Down

0 comments on commit 86bb7a1

Please sign in to comment.