Skip to content

Commit 2508f98

Browse files
committed
tests: ignore consecutive duplicates in lib check.
In some instances (e.g. building the CMake configuration in debug mode with the nightly rustc) the `--print native-static-libs` output of `cargo build` can include many repeating instances of a lib. While the order and duplicates are generally expected to be meaningful, many consecutive duplicates are not. This commit updates the `verify-static-libraries.py` script to collapse consecutive duplicates before doing the check of expected vs actual.
1 parent b5fc7d1 commit 2508f98

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tests/verify-static-libraries.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
)
1010

1111

12+
def uniquify_consecutive(items):
13+
r = []
14+
for i in items.split():
15+
if not (r and r[-1] == i):
16+
r.append(i)
17+
return r
18+
19+
1220
def main():
1321
# If you need to change the values here, be sure to update the values in
1422
# the README. Alternatively, it is possible that adding new libraries to
@@ -20,10 +28,9 @@ def main():
2028
elif sys.platform.startswith("win32"):
2129
want = (
2230
"advapi32.lib credui.lib kernel32.lib secur32.lib "
23-
"legacy_stdio_definitions.lib "
24-
"kernel32.lib advapi32.lib userenv.lib "
25-
"kernel32.lib kernel32.lib ws2_32.lib bcrypt.lib ntdll.lib msvcrt.lib "
26-
"legacy_stdio_definitions.lib"
31+
"legacy_stdio_definitions.lib kernel32.lib advapi32.lib "
32+
"bcrypt.lib kernel32.lib ntdll.lib userenv.lib ws2_32.lib "
33+
"kernel32.lib ws2_32.lib kernel32.lib msvcrt.lib"
2734
)
2835
else:
2936
want = ""
@@ -39,7 +46,8 @@ def main():
3946
print("could not find list of native static libraries, check for "
4047
"compilation errors")
4148
sys.exit(1)
42-
got = match.group(1).decode("ascii")
49+
got = uniquify_consecutive(match.group(1).decode("ascii"))
50+
want = uniquify_consecutive(want)
4351
if want != got:
4452
print(
4553
"got unexpected list of native static libraries, "

0 commit comments

Comments
 (0)