Files
roytam1 0224c91df2 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1170325 - Convert js::Vector into a template alias to mozilla::Vector with a single customized default argument. Also get rid of the CRTP support in mozilla::Vector (through mozilla::VectorBase) now that template aliasing is good enough, and make mozilla::Vector final so that people will use composition and not inheritance with it. (Inheritance plays poorly with movability and a few other things, in addition to messing up template argument deduction matching.) r=Waldo, patch sort of a tag-team between him and me (1f663fc5c1)
- Bug 1225682 - Don't use nsAuto{,C}String as class member variables in toolkit/. r=froydnj (7d47cd8c5f)
- Bug 1209184: Part 1b - [webext] Create a stream converter for localization placeholders. r=billm (1f5f88eccf)
- Bug 1167412 - Always register testing JS modules. r=ted (61246d3c38)
- Bug 1219442 - Re-write specialpowers as a restartless addon, r=jmaher (04b6494438)
- Bug 1217276 - Fix the handling of relativesrcdir for localized chrome data in FasterMake backend. r=mshal (9332ffaa1a)
- Bug 1210703 - fix toolkit theme overlap, r=dao (2b9dcead29)
- Bug 1169714 - Add requests to mach bootstrap SEARCH_PATH, r=jgriffin (35c7732f2e)
- Bug 917999 - Part 3.1 - Prepare taskcluster for a split test package. ;r=jlal (5f13e2c8eb)
- Bug 1168979 part 2 - Add symbol uploading as a build dependency; r=mrrrgn (d845c41588)
- Bug 1168979 part 3 - Clean up upload_symbol template. r=mrrrgn (517f318f5f)
- Bug 1168979 part 4 - Factor out building dependent tasks as a function; Create a task/post-builds for upload_symbols to live in; r=mrrrgn (a088748e8f)
- Bug 1176642 - Use deferred imports for taskcluster mach commands; r=glandium (a40d778717)
- Bug 1133074 - Use routes.json for Taskcluster routes; r=garndt (7a2d1ea735)
- Bug 1133074 - Use routes.json for mozharness TC uploads; r=jlund (20ea9b663d)
- Bug 1133074 - Make the gecko.v2 routes public; r=jlund,garndt (52d26f51cf)
- Bug 1200688: Support --interactive command line option r=jonasfj (ed5235c9e0)
- Bug 1194767 - use slugid 1.0.6 in ./mach taskcluster-graph command. r=wcosta (4b09e42cf4)
- Bug 1168979 part 5 - Add allowed_build_tasks to distinguish builds that require symbol uploading; r=mrrrgn (51af538d8c)
- Bug 1151124 - Add a simplified version of pymake's clinetoargv to mozbuild and use it. r=gps (ce8751951b)
- Bug 1201372: Remove workspace caches for try builds. r=garndt (33543ca777)
- Bug 1133074 - Add routes.json for taskcluster indexing; r=jonasfj (a979711f13)
- Bug 1195865 - Upload android l10n repacks to Taskcluster; r=jlund (e9201b24ab)
- Bug 1194709 - Add pushid support for mozharness routes; r=jlund (6b7a4d0e26)
- Bug 1195870 - Refactor mozharness TC uploading; r=jlund (48e4ef256f)
- Bug 1212942 - Add pushdate routes; r=garndt,jlund (6eaa6629c9)
- Bug 1214760 - prevent multiple tasks from using the same route in the gecko.v2 namespace; r=jonasfj (362c6fcaef)
- Bug 1171033 - Add taskcluster linux64 test configs (but not scheduled anywhere yet), r=dustin (a60327a9a7)
- Bug 1178388: Fix deferred imports for taskcluster-build command. r=gps (0d9688041e)
- Bug 1213283 - Add option to only print task names in |mach taskcluster-graph|, r=dustin (bef3b77463)
- Bug 1204346 - Add a white-list of caches for try server jobs; r=garndt (fdaa632636)
- Bug 1205574: Fix cache name typo in try white list. r=garndt (bcbe4c0e5e)
- Bug 1213011 - Allow post-build tasks to use build_{name,type,product} variables. r=garndt (69beb15547)
- Bug 1210687 - Remove PushbackIter now it's not used anymore. r=gps (7fbf140db2)
- Bug 1224452 - Move shell_quote to the shellutil module. r=gps (e4925f07c7)
- Bug 1227892 - Add a NO_COMPONENTS_MANIFEST moz.build variable. r=gps (6439a3be7c)
- Bug 1227892 - Emit a specialized object for chrome.manifest entries. r=gps (e0f16cdc58)
- Bug 1224452 - Quote passthru variables. r=gps (c21ff3bc27)
- Bug 1218042 - part 1 - pass an objdir into _build_db_line; r=mshal (385c352caa)
- Bug 1218042 - part 2 - make the CompileDB backend follow the backend protocol; r=mshal (6d5ccff583)
- Bug 1224452 - Use mozbuild.shellutil.split instead of shlex.shlex in mozbuild.compilation.util. r=gps (605ca5df51)
- Bug 1224452 - Add an expand_variables helper function to do simple make-like variable expansion. r=gps (3ea3651452)
- Bug 1224460 - Expand make variable references we get out of gyp. r=gps (df92f4b63c)
- Bug 1224452 - Better handle make variable references from gyp files. r=gps (0106b02b5d)
- Bug 1224452 - Straighten up a couple things in some moz.builds. r=gps (670222ac48)
- Bug 1228463 - Set MOZ_PIXMAN_{CFLAGS,LIBS} directly from PKG_CHECK_MODULES. r=mshal (3c70c986c0)
- Bug 1178266 - Link against libatomic when necessary. r=froydnj (951abf132f)
- Bug 1229293 - Enforce order when setting a HierarchicalStringList, and forbid reassignment. r=gps (c751dbf61d)
- Bug 1229279 - Add a specialized HierarchicalStringList class for ContextDerivedValue types. r=gps (a71776670a)
- Bug 1228444 - Don't silence "no preprocessor directives found" warnings for DIST_FILES. r=gps (aaf47470ab)
- Bug 1228444 - Validate that FINAL_TARGET_FILES source files exist. r=gps (afe3c9e054)
- Bug 1219228 - Generate correct source path of cpu-features.c. r=glandium (842f5ac893)
- Bug 1228444 - Make DIST_FILES a HierarchicalStringList, like FINAL_TARGET_FILES. r=gps (6d7a05be9b)
- Bug 1228444 - Make DIST_FILES a HierarchicalStringList, like FINAL_TARGET_FILES. r=gps (f3131b61ec)
- Bug 1229226 - Remove preprocessing support for RESOURCE_FILES. r=gps (e867dadad0)
- Bug 1229233 - Properly skip the top-level directory in the RecursiveMake backend. r=gps (188856f8d7)
- Bug 1229241 - Reject FINAL_TARGET{,_PP}_FILES along DIST_INSTALL = False. r=gps (9031cbb9b8)
- Bug 1229233 - Skip building XPIDL when there aren't any in the FasterMake backend. r=gps (4b657fcf99)
- Bug 1229241 - Redirect EXTRA{_PP}_COMPONENTS to FINAL_TARGET{,_PP}_FILES.components. r=gps (388754db86)
- Bug 1229241 - Differentiate preprocessed and non-preprocessed JS preffiles. r=gps (c130ef8f59)
- Bug 1229226 - Reject RESOURCE_FILES along DIST_SUBDIR or XPI_NAME. r=gps (ab798a04b1)
- Bug 1229241 - Use FINAL_TARGET{,_PP}_FILES for JS_PREFERENCE{,_PP}_FILES. r=gps (e6bbfed921)
- Bug 1227892 - Add basic tests for IS_COMPONENT/NO_COMPONENTS_MANIFEST. r=gps (5c2f0bf3cb)
- Bug 1229241 - Use FINAL_TARGET{,_PP}_FILES for EXTRA{,_PP}_JS_MODULES. r=gps (8f8267f8ad)
- Bug 1229245 - Don't store the target in FinalTarget{,Preprocessed}Files instances. r=gps (394b7d92c8)
- Bug 1229245 - Use a FinalTargetFiles-like object for TESTING_JS_MODULES. r=gps (101489d644)
- Bug 1229279 - Use mozbuild.context.Path for FINAL_TARGET{_PP}_FILES. r=gps (5aa7034ce6)
- Bug 1229341 - Remove HierarchicalStringListWithFlagsFactory. r=gps (5da80b69bf)
- Bug 1229341 - Remove .source flag on BRANDING_FILES. r=gps (bf23c694b2)
- Bug 1229233 - Use SourcePaths for CONFIGURE_SUBST_FILES and CONFIGURE_DEFINE_FILES. r=gps (1695a94e90)
- bug 1160185 - support GENERATED_FILES in EXPORTS. r=glandium (24b469652f)
- Bug 1229241 - Support merging HierarchicalStringLists. r=gps (bc0ed26557)
- Bug 1220000 - Unconditionally include EXTRA_MDDEPEND_FILES so callers get what they expect. r=glandium (a039177317)
- Bug 1230355 - Remove include_deps. r=mshal (8c3205e672)
- Bug 1222591 - "nsMsgUtils.cpp:52:10: fatal error: 'nsProtocolProxyService.h' file not found". r=gps f=aleth (a1b6ef742c)
- Bug 1230067 - Normalize install target when processing JarManifestParser data in FasterMake backend. r=gps (c875719c52)
- Bug 1191209 - Rebuild XPT files when the list of corresponding IDL files changed. r=gps (7018d28e85)
- Bug 1223593 - Make depsdir optional in xpidl-process.py; r=glandium (9439dd4f6e)
- Bug 1229241 - Allow moz.build special variables to be set, as long as the value is not modified. r=gps (1553c6a9b5)
- sort of quick fix for arcticfox/palemoon (562745788a)
- Bug 1219521 - Add imported python modules in the tree to dependencie of GENERATED_FILES scripts. r=glandium (6a73afa6f4)
- non-android of Bug 1108782 - Part 1: straighten out Java classpaths. r=glandium (c374670020)
- part of Bug 1108782 - Part 2: Explode AAR files at configure time. r=glandium (ba69c238ef)
- Bug 1224460 - Avoid make variable references in TK_CFLAGS, TK_LIBS, MOZ_CAIRO_CFLAGS, MOZ_ICU_CFLAGS and CAIRO_FT_CFLAGS. r=gps (bdbeed2237)
- Typo fix for bug 1224460 breaking Gtk+2 builds. r=me (3a79e9d993)
- Bug 1216901 - Always update backend output list files mtime from the base backend class. r=mshal (33c581c475)
- No bug - Message which upstream pushhead is used in |mach artifact|. r=me (e3cfbd2f50)
- Bug 1230409: Implement dummy HeapOffset members for non-ion builds; r=luke (74158a1271)
- some webapprt and mozcrash stuff (2c303646f7)
- Bug 1228369: Rename CodeOffset::use/used into bind/bound; r=luke (90d1b88697)
- fix duplicated entries also for mac and windows (475bdf9a15)
- Bug 1228340: Remove the js_ prefix in front of IonOptimizationsLevel; r=h4writer (44b79061b3)
- Bug 1229196 - Fix MSVC C4334 "was 64-bit shift intended" warning in js/src/asmjs. r=sunfish (debed181c9)
- Bug 1210642 - s/APP_BUILDID/MOZ_APP_BUILDID/ to use the same variable name across products. r=gps (da9fc7a443)
- Bug 1230060 - Use process_install_manifest's --track option in the FasterMake backend. r=gps (a0ffbc880e)
- Bug 1229233 - Ensure the target directory for copies exists in the FasterMake backend. r=gps (80c92303e6)
- Bug 1214464 - Don't detect leaks during ICU build; r=glandium (c0277a56e5)
- Bug 864843 - Part 3. Add build config of ICU for Android r=glandium (8fb16f3450)
- Bug 1164921 - part 2 - remove now-obsolete --enable-android-libstdcxx; r=glandium (5582d619c0)
- Bug 1229541 - Turn NSPR_CFLAGS, NSS_CFLAGS, MOZ_JPEG_CFLAGS, MOZ_PNG_CFLAGS and MOZ_ZLIB_CFLAGS into AC_SUBST_LISTs. r=mshal (333f8c851d)
- Bug 1142352 - Add a configure test for the gcc version of the host compiler when cross compiling. r=glandium (e5baa698f5)
- Bug 1142420 - Require that the same compiler version be used for C and C++ (at the very least, so that our version checks are valid for both). r=glandium (442ff81898)
- Bug 1228068 - Always set MOZ_USING_COMPILER_WRAPPER when a compiler wrapper is involved. r=gps on a CLOSED TREE (5a7c5aa53e)
- fix more dupes (b67b95d705)
2023-04-20 11:43:27 +08:00

168 lines
8.2 KiB
Python

# Licensed under the Mozilla Public Licence 2.0.
# https://www.mozilla.org/en-US/MPL/2.0
import uuid
import slugid
def testEncode():
""" Test that we can correctly encode a "non-nice" uuid (with first bit
set) to its known slug. The specific uuid was chosen since it has a slug
which contains both `-` and `_` characters."""
# 10000000010011110011111111001000110111111100101101001011000001101000100111111011101011101111101011010101111000011000011101010100....
# <8 ><0 ><4 ><f ><3 ><f ><c ><8 ><d ><f ><c ><b ><4 ><b ><0 ><6 ><8 ><9 ><f ><b ><a ><e ><f ><a ><d ><5 ><e ><1 ><8 ><7 ><5 ><4 >
# < g >< E >< 8 >< _ >< y >< N >< _ >< L >< S >< w >< a >< J >< - >< 6 >< 7 >< 6 >< 1 >< e >< G >< H >< V >< A >
uuid_ = uuid.UUID('{804f3fc8-dfcb-4b06-89fb-aefad5e18754}')
expectedSlug = 'gE8_yN_LSwaJ-6761eGHVA'
actualSlug = slugid.encode(uuid_)
assert expectedSlug == actualSlug, "UUID not correctly encoded into slug: '" + expectedSlug + "' != '" + actualSlug + "'"
def testDecode():
""" Test that we can decode a "non-nice" slug (first bit of uuid is set)
that begins with `-`"""
# 11111011111011111011111011111011111011111011111001000011111011111011111111111111111111111111111111111111111111111111111111111101....
# <f ><b ><e ><f ><b ><e ><f ><b ><e ><f ><b ><e ><4 ><3 ><e ><f ><b ><f ><f ><f ><f ><f ><f ><f ><f ><f ><f ><f ><f ><f ><f ><d >
# < - >< - >< - >< - >< - >< - >< - >< - >< Q >< - >< - >< - >< _ >< _ >< _ >< _ >< _ >< _ >< _ >< _ >< _ >< Q >
slug = '--------Q--__________Q'
expectedUuid = uuid.UUID('{fbefbefb-efbe-43ef-bfff-fffffffffffd}')
actualUuid = slugid.decode(slug)
assert expectedUuid == actualUuid, "Slug not correctly decoded into uuid: '" + str(expectedUuid) + "' != '" + str(actualUuid) + "'"
def testUuidEncodeDecode():
""" Test that 10000 v4 uuids are unchanged after encoding and then decoding them"""
for i in range(0, 10000):
uuid1 = uuid.uuid4()
slug = slugid.encode(uuid1)
uuid2 = slugid.decode(slug)
assert uuid1 == uuid2, "Encode and decode isn't identity: '" + str(uuid1) + "' != '" + str(uuid2) + "'"
def testSlugDecodeEncode():
""" Test that 10000 v4 slugs are unchanged after decoding and then encoding them."""
for i in range(0, 10000):
slug1 = slugid.v4()
uuid_ = slugid.decode(slug1)
slug2 = slugid.encode(uuid_)
assert slug1 == slug2, "Decode and encode isn't identity"
def testSpreadNice():
""" Make sure that all allowed characters can appear in all allowed
positions within the "nice" slug. In this test we generate over a thousand
slugids, and make sure that every possible allowed character per position
appears at least once in the sample of all slugids generated. We also make
sure that no other characters appear in positions in which they are not
allowed.
base 64 encoding char -> value:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_
0 1 2 3 4 5 6
0123456789012345678901234567890123456789012345678901234567890123
e.g. from this we can see 'j' represents 35 in base64
The following comments show the 128 bits of the v4 uuid in binary, hex and
base 64 encodings. The 6 fixed bits (`0`/`1`) according to RFC 4122, plus
the first (most significant) fixed bit (`0`) are shown among the 121
arbitrary value bits (`.`/`x`). The `x` means the same as `.` but just
highlights which bits are grouped together for the respective encoding.
schema:
<..........time_low............><...time_mid...><time_hi_+_vers><clk_hi><clk_lo><.....................node.....................>
bin: 0xxx............................................0100............10xx............................................................
hex: $A <01><02><03><04><05><06><07><08><09><10><11> 4 <13><14><15> $B <17><18><19><20><21><22><23><24><25><26><27><28><29><30><31>
=> $A in {0, 1, 2, 3, 4, 5, 6, 7} (0b0xxx)
=> $B in {8, 9, A, B} (0b10xx)
bin: 0xxxxx..........................................0100xx......xxxx10............................................................xx0000
b64: $C < 01 >< 02 >< 03 >< 04 >< 05 >< 06 >< 07 > $D < 09 > $E < 11 >< 12 >< 13 >< 14 >< 15 >< 16 >< 17 >< 18 >< 19 >< 20 > $F
=> $C in {A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, a, b, c, d, e, f} (0b0xxxxx)
=> $D in {Q, R, S, T} (0b0100xx)
=> $E in {C, G, K, O, S, W, a, e, i, m, q, u, y, 2, 6, -} (0bxxxx10)
=> $F in {A, Q, g, w} (0bxx0000)"""
charsAll = ''.join(sorted('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'))
# 0 - 31: 0b0xxxxx
charsC = ''.join(sorted('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef'))
# 16, 17, 18, 19: 0b0100xx
charsD = ''.join(sorted('QRST'))
# 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62: 0bxxxx10
charsE = ''.join(sorted('CGKOSWaeimquy26-'))
# 0, 16, 32, 48: 0bxx0000
charsF = ''.join(sorted('AQgw'))
expected = [charsC, charsAll, charsAll, charsAll, charsAll, charsAll, charsAll, charsAll, charsD, charsAll, charsE, charsAll, charsAll, charsAll, charsAll, charsAll, charsAll, charsAll, charsAll, charsAll, charsAll, charsF]
spreadTest(slugid.nice, expected)
def testSpreadV4():
""" This test is the same as niceSpreadTest but for slugid.v4() rather than
slugid.nice(). The only difference is that a v4() slug can start with any of
the base64 characters since the first six bits of the uuid are random."""
charsAll = ''.join(sorted('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'))
# 16, 17, 18, 19: 0b0100xx
charsD = ''.join(sorted('QRST'))
# 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62: 0bxxxx10
charsE = ''.join(sorted('CGKOSWaeimquy26-'))
# 0, 16, 32, 48: 0bxx0000
charsF = ''.join(sorted('AQgw'))
expected = [charsAll, charsAll, charsAll, charsAll, charsAll, charsAll, charsAll, charsAll, charsD, charsAll, charsE, charsAll, charsAll, charsAll, charsAll, charsAll, charsAll, charsAll, charsAll, charsAll, charsAll, charsF]
spreadTest(slugid.v4, expected)
def spreadTest(generator, expected):
""" `spreadTest` runs a test against the `generator` function, to check that
when calling it 64*40 times, the range of characters per string position it
returns matches the array `expected`, where each entry in `expected` is a
string of all possible characters that should appear in that position in the
string, at least once in the sample of 64*40 responses from the `generator`
function"""
# k is an array which stores which characters were found at which
# positions. It has one entry per slugid character, therefore 22 entries.
# Each entry is a dict with a key for each character found, and its value
# as the number of times that character appeared at that position in the
# slugid in the large sample of slugids generated in this test.
k = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]
# Generate a large sample of slugids, and record what characters appeared
# where... A monte-carlo test has demonstrated that with 64 * 20
# iterations, no failure occurred in 1000 simulations, so 64 * 40 should be
# suitably large to rule out false positives.
for i in range(0, 64 * 40):
slug = generator()
assert len(slug) == 22
for j in range(0, 22):
if slug[j] in k[j]:
k[j][slug[j]] = k[j][slug[j]] + 1
else:
k[j][slug[j]] = 1
# Compose results into an array `actual`, for comparison with `expected`
actual = []
for j in range(0, len(k)):
actual.append('')
for a in k[j].keys():
if k[j][a] > 0:
actual[j] += a
# sort for easy comparison
actual[j] = ''.join(sorted(actual[j]))
assert arraysEqual(expected, actual), "In a large sample of generated slugids, the range of characters found per character position in the sample did not match expected results.\n\nExpected: " + str(expected) + "\n\nActual: " + str(actual)
def arraysEqual(a, b):
""" returns True if arrays a and b are equal"""
return cmp(a, b) == 0