diff --git a/.github/workflows/dart.yaml b/.github/workflows/dart.yaml index d992b209..264d8c46 100644 --- a/.github/workflows/dart.yaml +++ b/.github/workflows/dart.yaml @@ -6,12 +6,12 @@ on: branches: [main] paths: - ".github/workflows/dart.yaml" - - "executors/dart**" + - "executors/dart/**" push: branches: [main] paths: - ".github/workflows/dart.yaml" - - "executors/dart**" + - "executors/dart/**" schedule: - cron: "0 0 * * 0" # weekly @@ -28,9 +28,9 @@ jobs: steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c + - uses: dart-lang/setup-dart@a73965b3c99b30eb092908ce56c429eff91f9634 with: - sdk: 3.10.0 + sdk: 3.12.0 - run: dart pub get diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index b6116414..9ca42fdb 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Install prerequisites run: | - apt-get update && apt-get install -y sudo python3 wget unzip logrotate curl jq python3-requests python3-jsonschema build-essential clang maven + apt-get update && apt-get install -y sudo python3 wget unzip logrotate curl jq python3-requests python3-jsonschema build-essential clang maven git - name: Free up some disk space run: | echo "Available storage before:" @@ -49,9 +49,9 @@ jobs: path: gh-cache key: ${{ runner.os }}-icu4c-binaries - name: Setup version of Dart - uses: dart-lang/setup-dart@v1 + uses: dart-lang/setup-dart@a73965b3c99b30eb092908ce56c429eff91f9634 with: - sdk: 3.10.0 + sdk: 3.12.0 - name: Set version of Rust uses: actions-rs/toolchain@v1 with: diff --git a/executors/dart/bin/executor.dart b/executors/dart/bin/executor.dart index 5973107e..5365f056 100644 --- a/executors/dart/bin/executor.dart +++ b/executors/dart/bin/executor.dart @@ -7,6 +7,7 @@ import 'package:collection/collection.dart'; import 'package:dart_executor/collator.dart'; import 'package:dart_executor/datetime_format.dart'; import 'package:dart_executor/lang_names.dart'; +import 'package:dart_executor/likely_subtags.dart'; import 'package:dart_executor/list_format.dart'; import 'package:dart_executor/numberformat.dart'; import 'package:dart_executor/plural_rules.dart'; @@ -56,14 +57,9 @@ void main() { TestTypes.decimal_fmt => testDecimalFormatWrapped(line), TestTypes.number_fmt => testDecimalFormatWrapped(line), TestTypes.datetime_fmt => testDateTimeFmt(line), - TestTypes.display_names => throw UnimplementedError( - 'display_names is not supported yet', - ), + TestTypes.display_names => testLangNames(line), TestTypes.lang_names => testLangNames(line), - // TestTypes.likely_subtags => testLikelySubtags(line), - TestTypes.likely_subtags => throw UnimplementedError( - 'likely_subtags is not supported yet, as the Locale object is not yet migrated to ICU4X', - ), + TestTypes.likely_subtags => testLikelySubtags(line), TestTypes.list_fmt => testListFmt(line), TestTypes.plural_rules => testPluralRules(line), null => throw ArgumentError.value( diff --git a/executors/dart/bin/make_runnable_by_node.dart b/executors/dart/bin/make_runnable_by_node.dart index 5df91aab..9f88ee0b 100644 --- a/executors/dart/bin/make_runnable_by_node.dart +++ b/executors/dart/bin/make_runnable_by_node.dart @@ -22,6 +22,10 @@ Future main(List args) async { name: 'testPluralRules', argNames: ['encoded'], ), + 'likely_subtags': ExportFunction( + name: 'testLikelySubtags', + argNames: ['encoded'], + ), 'list_format': ExportFunction(name: 'testListFmt', argNames: ['encoded']), 'datetimeformat': ExportFunction( name: 'testDateTimeFmt', diff --git a/executors/dart/bin/web_wrappers/likely_subtags_executor.dart b/executors/dart/bin/web_wrappers/likely_subtags_executor.dart new file mode 100644 index 00000000..aeb0e1b6 --- /dev/null +++ b/executors/dart/bin/web_wrappers/likely_subtags_executor.dart @@ -0,0 +1,5 @@ +import 'package:dart_executor/likely_subtags.dart'; + +void main(List args) { + testLikelySubtags(args.first); +} diff --git a/executors/dart/lib/datetime_format.dart b/executors/dart/lib/datetime_format.dart index 9eb57b7d..6e9bdaed 100644 --- a/executors/dart/lib/datetime_format.dart +++ b/executors/dart/lib/datetime_format.dart @@ -119,15 +119,26 @@ String testDateTimeFmt(String jsonEncoded) { locale, timePrecision, ); + final offset = offsetSeconds != null + ? Duration(seconds: offsetSeconds) + : Duration.zero; + final dateToFormat = testDate!.add(offset); + + final isZoned = + formatter is DateTimeFormatter && + timeZoneName != null && + ((semanticSkeleton ?? '').contains('Z') || + timeStyle == 'full' || + testOptionsJson.containsKey('zoneStyle') || + (skeleton != null && RegExp(r'[zvOV]').hasMatch(skeleton))); + String formattedDt; - if (formatter is DateTimeFormatter && - (semanticSkeleton ?? '').contains('Z')) { - final offset = Duration(seconds: offsetSeconds!); + if (isZoned) { final zoneStyle = testOptionsJson['zoneStyle'] as String?; final zonedFormatter = getZonedFormatter(zoneStyle, formatter, skeleton); - formattedDt = zonedFormatter.format(testDate!.add(offset), timeZoneName!); + formattedDt = zonedFormatter.format(dateToFormat, timeZoneName); } else { - formattedDt = formatter.format(testDate!); + formattedDt = formatter.format(dateToFormat); } returnJson['result'] = formattedDt; } on Exception catch (e) { @@ -137,8 +148,8 @@ String testDateTimeFmt(String jsonEncoded) { } returnJson['actual_options'] = { 'locale': locale.toString(), - if (dateStyle != null) 'dateStyle': dateStyle, - if (timeStyle != null) 'timeStyle': timeStyle, + 'dateStyle': ?dateStyle, + 'timeStyle': ?timeStyle, if (yearStyle != null) 'yearStyle': yearStyle.name, if (calendar != null) 'calendar': calendar.jsName, }; @@ -234,11 +245,11 @@ ZonedDateTimeFormatter getZonedFormatter( return switch (timeZoneStyle) { 'short' => formatter.withTimeZoneShort(), 'specific' => formatter.withTimeZoneShort(), - 'full' => formatter.withTimeZoneLongGeneric(), + 'full' => formatter.withTimeZoneLong(), 'generic' => formatter.withTimeZoneLongGeneric(), 'location' => formatter.withTimeZoneShort(), - 'offset' => formatter.withTimeZoneLongGeneric(), - null => formatter.withTimeZoneLongGeneric(), + 'offset' => formatter.withTimeZoneLongOffset(), + null => formatter.withTimeZoneLong(), String() => throw Exception('Unknown time zone style `$timeZoneStyle`'), }; } @@ -250,7 +261,6 @@ DateTimeFormatter getFormatterForStyle( Locale locale, TimePrecision? timePrecision, ) { - print((dateStyle, timeStyle, yearStyle)); return switch ((dateStyle, timeStyle, yearStyle)) { ('medium', null, null) => DateTimeFormat.yearMonthDay( locale: locale, diff --git a/executors/dart/lib/likely_subtags.dart b/executors/dart/lib/likely_subtags.dart new file mode 100644 index 00000000..e161dcd9 --- /dev/null +++ b/executors/dart/lib/likely_subtags.dart @@ -0,0 +1,29 @@ +import 'dart:convert'; + +import 'package:intl4x/locale.dart'; + +String testLikelySubtags(String jsonEncoded) { + final json = jsonDecode(jsonEncoded) as Map; + final label = json['label']; + final localeStr = json['locale'] as String; + final option = json['option'] as String; + + final returnJson = {'label': label}; + + try { + final locale = Locale.parse(localeStr); + if (option == 'maximize') { + returnJson['result'] = locale.maximize().toLanguageTag(); + } else if (option == 'minimize' || option == 'minimizeFavorRegion') { + returnJson['result'] = locale.minimize().toLanguageTag(); + } else { + returnJson['error_type'] = 'unsupported'; + returnJson['unsupported'] = 'Option $option not supported'; + return jsonEncode(returnJson); + } + } catch (e) { + returnJson['error'] = e.toString(); + } + + return jsonEncode(returnJson); +} diff --git a/executors/dart/lib/plural_rules.dart b/executors/dart/lib/plural_rules.dart index 82da0ca1..7a319546 100644 --- a/executors/dart/lib/plural_rules.dart +++ b/executors/dart/lib/plural_rules.dart @@ -80,8 +80,16 @@ String testPluralRules(String jsonEncoded) { : PluralRules(locale: locale); try { - final result = pluralRules.select(sample); - returnJson['result'] = result.name; + final result = pluralRules.select( + sample, + zero: 'zero', + one: 'one', + two: 'two', + few: 'few', + many: 'many', + other: 'other', + ); + returnJson['result'] = result; } catch (error) { returnJson['error'] = 'PLURAL RULES UNKNOWN ERROR: ${error.toString()}'; } diff --git a/executors/dart/lib/version.dart b/executors/dart/lib/version.dart index 012e4e6f..96db806b 100644 --- a/executors/dart/lib/version.dart +++ b/executors/dart/lib/version.dart @@ -1,2 +1,2 @@ /// This file is autogenerated by bin/set_version.dart, do not modify manually. -const intl4xVersion = '0.17.0'; +const intl4xVersion = '1.0.0-alpha.3-wip'; diff --git a/executors/dart/out/executor.js b/executors/dart/out/executor.js index 9fb14a78..2c8b95e1 100644 --- a/executors/dart/out/executor.js +++ b/executors/dart/out/executor.js @@ -28,6 +28,8 @@ let datetime_fmt = require('./datetimeformat.js'); let list_fmt = require('./list_format.js'); +let likely_subtags = require('./likely_subtags.js'); + const { dartVersion } = require('./version.js') /** @@ -136,7 +138,7 @@ rl.on('line', function (line) { outputLine = collator.testCollation(parsedJson); } else if (test_type == "decimal_fmt" || test_type == "number_fmt") { outputLine = numberformatter.testDecimalFormat(parsedJson, doLogInput > 0, process.version); - } else if (test_type == "language_display_name" || test_type == "lang_names") { + } else if (test_type == "language_display_name" || test_type == "lang_names" || test_type == "display_names") { outputLine = lang_names.testLangNames(parsedJson); } else if (test_type == "plural_rules") { outputLine = plural_rules.testPluralRules(parsedJson); @@ -144,6 +146,8 @@ rl.on('line', function (line) { outputLine = datetime_fmt.testDateTimeFmt(parsedJson, doLogInput > 0, process.version); } else if (test_type == "list_fmt") { outputLine = list_fmt.testListFmt(parsedJson); + } else if (test_type == "likely_subtags") { + outputLine = likely_subtags.testLikelySubtags(parsedJson); } else { outputLine = { 'error': 'unknown test type', 'testId': testId, diff --git a/executors/dart/out/likely_subtags.js b/executors/dart/out/likely_subtags.js new file mode 100644 index 00000000..dfa074ad --- /dev/null +++ b/executors/dart/out/likely_subtags.js @@ -0,0 +1,6 @@ +var tools = require('./likely_subtagsDart'); +module.exports = { + testLikelySubtags: function (json) { + return JSON.parse(tools.testLikelySubtags(JSON.stringify(json))); + } +}; diff --git a/executors/dart/out/version.js b/executors/dart/out/version.js index 9d756391..f6fc6b28 100644 --- a/executors/dart/out/version.js +++ b/executors/dart/out/version.js @@ -1,2 +1,2 @@ -const dartVersion = "0.17.0"; +const dartVersion = "1.0.0-alpha.3-wip"; module.exports = { dartVersion }; diff --git a/executors/dart/pubspec.lock b/executors/dart/pubspec.lock index 539925d1..ba919704 100644 --- a/executors/dart/pubspec.lock +++ b/executors/dart/pubspec.lock @@ -5,18 +5,18 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "5b7468c326d2f8a4f630056404ca0d291ade42918f4a3c6233618e724f39da8e" + sha256: f6526c100095fd63a916824e3da344bbbd50c25c8f56bcd52d13c59d35bbe422 url: "https://pub.dev" source: hosted - version: "92.0.0" + version: "104.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: "70e4b1ef8003c64793a9e268a551a82869a8a96f39deb73dea28084b0e8bf75e" + sha256: "6c6d751533496152e78f71c46ad001260c5e74e0f9ec1f1cbc165a0467c086d6" url: "https://pub.dev" source: hosted - version: "9.0.0" + version: "14.0.0" args: dependency: transitive description: @@ -29,10 +29,10 @@ packages: dependency: transitive description: name: async - sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37 url: "https://pub.dev" source: hosted - version: "2.13.0" + version: "2.13.1" boolean_selector: dependency: transitive description: @@ -61,10 +61,10 @@ packages: dependency: transitive description: name: code_assets - sha256: "83ccdaa064c980b5596c35dd64a8d3ecc68620174ab9b90b6343b753aa721687" + sha256: cfd4f5f575a49c5f10ca856e9846073f1e6c3ee94912377eea5f6cefc5272941 url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "2.0.0" collection: dependency: "direct main" description: @@ -85,10 +85,10 @@ packages: dependency: transitive description: name: coverage - sha256: "5da775aa218eaf2151c721b16c01c7676fbfdd99cebba2bf64e8b807a28ff94d" + sha256: "956a3de0725ca232ad353565a8290d3357592bf4250f6f298a185e2d949c5d3d" url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.15.1" crypto: dependency: transitive description: @@ -101,10 +101,10 @@ packages: dependency: transitive description: name: ffi - sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418" + sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.2.0" file: dependency: transitive description: @@ -133,10 +133,10 @@ packages: dependency: transitive description: name: hooks - sha256: "5d309c86e7ce34cd8e37aa71cb30cb652d3829b900ab145e4d9da564b31d59f7" + sha256: eaac480a35ec0814146c2c48d96aaa829e0e44a7662c88ae84c9edf4bc35651f url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "2.2.0" http: dependency: transitive description: @@ -162,21 +162,22 @@ packages: source: hosted version: "4.1.2" icu4x: - dependency: transitive + dependency: "direct main" description: name: icu4x - sha256: "8c2f3ed5f860c68be13076e43685f49330956a8a8c351c9af7920606be411368" + sha256: "6890e55223422b5bbde95060202d7438dba88d3347ec3598f91d73ff45e64c15" url: "https://pub.dev" source: hosted - version: "2.1.0-dev.1" + version: "2.3.1" intl4x: dependency: "direct main" description: - name: intl4x - sha256: "30170321747219904977b4826dbd5156e34f407876f87695d8b8167da5955d20" - url: "https://pub.dev" - source: hosted - version: "0.17.0" + path: "pkgs/intl4x" + ref: a3c72590b83f60c3631ece8064d7990840eed187 + resolved-ref: a3c72590b83f60c3631ece8064d7990840eed187 + url: "https://github.com/dart-lang/i18n.git" + source: git + version: "1.0.0-alpha.3-wip" io: dependency: transitive description: @@ -189,18 +190,18 @@ packages: dependency: transitive description: name: json_annotation - sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + sha256: "2a743920d81b7910627f68ee2c9ac1fc0bfee32b9fc3403587d7c6791ca12f80" url: "https://pub.dev" source: hosted - version: "4.9.0" + version: "4.12.0" lints: dependency: "direct dev" description: name: lints - sha256: a5e2b223cb7c9c8efdc663ef484fdd95bb243bff242ef5b13e26883547fce9a0 + sha256: "12f842a479589fea194fe5c5a3095abc7be0c1f2ddfa9a0e76aed1dbd26a87df" url: "https://pub.dev" source: hosted - version: "6.0.0" + version: "6.1.0" logging: dependency: transitive description: @@ -213,18 +214,18 @@ packages: dependency: transitive description: name: matcher - sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6" + sha256: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd" url: "https://pub.dev" source: hosted - version: "0.12.18" + version: "0.12.20" meta: dependency: "direct dev" description: name: meta - sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + sha256: "307249ce4ff29d58a18e97f6345f539382eb9c9c29ecda628900f31de0443dd9" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.19.0" mime: dependency: transitive description: @@ -237,10 +238,10 @@ packages: dependency: transitive description: name: native_toolchain_c - sha256: "89e83885ba09da5fdf2cdacc8002a712ca238c28b7f717910b34bcd27b0d03ac" + sha256: "9d233b6f2d9c52e1a2b5fbe70451d2c10ac674d3bb419d0ec8de14989d437c26" url: "https://pub.dev" source: hosted - version: "0.17.4" + version: "0.19.4" node_preamble: dependency: "direct main" description: @@ -253,10 +254,10 @@ packages: dependency: transitive description: name: package_config - sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc + sha256: ffcf4cf3d6c0b74ac43708d9f56625506e8a68aa935abe9d267a7330f320eb5d url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "3.0.0" path: dependency: transitive description: @@ -265,6 +266,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" + platform: + dependency: transitive + description: + name: platform + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + url: "https://pub.dev" + source: hosted + version: "3.1.6" pool: dependency: transitive description: @@ -273,6 +282,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.2" + process: + dependency: transitive + description: + name: process + sha256: "4242ba3508d37e01808bdf71ad1d5bb93a8d671bf2e7450e6b1b353fb0808891" + url: "https://pub.dev" + source: hosted + version: "5.0.6" pub_semver: dependency: transitive description: @@ -293,10 +310,10 @@ packages: dependency: transitive description: name: record_use - sha256: d3d59b18ca7aa1ce689bb3b3fd982bbebdfcd9e89f977576486a55e3b0f19a27 + sha256: "1cb8564af8d43b464294411db9217f5ec04891c6f22ee2c32d73ae05e88a6bd2" url: "https://pub.dev" source: hosted - version: "0.4.2" + version: "1.1.1" shelf: dependency: transitive description: @@ -349,10 +366,10 @@ packages: dependency: transitive description: name: source_span - sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab" url: "https://pub.dev" source: hosted - version: "1.10.1" + version: "1.10.2" stack_trace: dependency: transitive description: @@ -389,34 +406,34 @@ packages: dependency: "direct dev" description: name: test - sha256: "77cc98ea27006c84e71a7356cf3daf9ddbde2d91d84f77dbfe64cf0e4d9611ae" + sha256: "0d5ba5602ec3baa28c8ce365e1efc5575969c765f45c554a3e167dc7945b9c30" url: "https://pub.dev" source: hosted - version: "1.28.0" + version: "1.31.2" test_api: dependency: transitive description: name: test_api - sha256: "19a78f63e83d3a61f00826d09bc2f60e191bf3504183c001262be6ac75589fb8" + sha256: "475610b2aa23c19687cce2961e44b0cc57cafe220f67c2b80201231b2a07fbe7" url: "https://pub.dev" source: hosted - version: "0.7.8" + version: "0.7.13" test_core: dependency: transitive description: name: test_core - sha256: f1072617a6657e5fc09662e721307f7fb009b4ed89b19f47175d11d5254a62d4 + sha256: a39c204a4fc7a7ccb04a2b985e359fda3cc37e45e0b8ac61c3fb1a05aa832132 url: "https://pub.dev" source: hosted - version: "0.6.14" + version: "0.6.19" timezone: dependency: transitive description: name: timezone - sha256: dd14a3b83cfd7cb19e7888f1cbc20f258b8d71b54c06f79ac585f14093a287d1 + sha256: "981d1020d6ef8fe1e7b3de5054e5b25579ae7c403d7734adc508ffc47668e9cb" url: "https://pub.dev" source: hosted - version: "0.10.1" + version: "0.11.1" typed_data: dependency: transitive description: @@ -429,18 +446,18 @@ packages: dependency: transitive description: name: vm_service - sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" + sha256: "0016aef94fc66495ac78af5859181e3f3bf2026bd8eecc72b9565601e19ab360" url: "https://pub.dev" source: hosted - version: "15.0.2" + version: "15.2.0" watcher: dependency: transitive description: name: watcher - sha256: f52385d4f73589977c80797e60fe51014f7f2b957b5e9a62c3f6ada439889249 + sha256: "1398c9f081a753f9226febe8900fce8f7d0a67163334e1c94a2438339d79d635" url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" web: dependency: transitive description: @@ -482,4 +499,4 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.10.0 <4.0.0" + dart: ">=3.12.0 <4.0.0" diff --git a/executors/dart/pubspec.yaml b/executors/dart/pubspec.yaml index 0993b715..2c5aaa08 100644 --- a/executors/dart/pubspec.yaml +++ b/executors/dart/pubspec.yaml @@ -2,18 +2,23 @@ name: dart_executor publish_to: none environment: - sdk: ^3.10.0 + sdk: ^3.12.0 dependencies: collection: ^1.19.1 - intl4x: 0.17.0 + icu4x: ^2.3.1 + intl4x: + git: + url: https://github.com/dart-lang/i18n.git + path: pkgs/intl4x + ref: a3c72590b83f60c3631ece8064d7990840eed187 node_preamble: ^2.0.2 pubspec_lock_parse: ^2.2.0 dev_dependencies: - lints: ^6.0.0 - meta: ^1.17.0 - test: ^1.28.0 + lints: ^6.1.0 + meta: ^1.18.3 + test: ^1.31.2 hook: diff --git a/executors/dart/test/misc_test.dart b/executors/dart/test/misc_test.dart index 24f1e4f2..143511df 100644 --- a/executors/dart/test/misc_test.dart +++ b/executors/dart/test/misc_test.dart @@ -4,13 +4,14 @@ import 'dart:convert'; import 'package:dart_executor/collator.dart'; import 'package:dart_executor/datetime_format.dart'; import 'package:dart_executor/lang_names.dart'; +import 'package:dart_executor/likely_subtags.dart'; import 'package:dart_executor/numberformat.dart'; import 'package:intl4x/datetime_format.dart'; import 'package:meta/meta.dart'; import 'package:test/test.dart'; -/// Run using `dart --enable-experiment=native-assets,record-use test -p chrome` for dart_web -/// and `dart --enable-experiment=native-assets,record-use test` for dart_native +/// Run using `dart --enable-experiment=record-use test -p chrome` for dart_web +/// and `dart --enable-experiment=record-use test` for dart_native void main() { testWithFormatting('Check number format output', () { @@ -60,6 +61,49 @@ void main() { expect(decoded['result'], 'Spanish'); }); + testWithFormatting('Check likely subtags maximize', () { + final inputLine = { + 'label': 'subtags_max', + 'locale': 'en', + 'option': 'maximize', + }; + final outputLine = testLikelySubtags(jsonEncode(inputLine)); + final decoded = jsonDecode(outputLine) as Map; + expect(decoded['result'], 'en-Latn-US'); + }); + + testWithFormatting('Check likely subtags minimize', () { + final inputLine = { + 'label': 'subtags_min', + 'locale': 'en-Latn-US', + 'option': 'minimize', + }; + final outputLine = testLikelySubtags(jsonEncode(inputLine)); + final decoded = jsonDecode(outputLine) as Map; + expect(decoded['result'], 'en'); + }); + + testWithFormatting('Check datetime format with timezone', () { + final inputLine = { + 'label': '00588', + 'locale': 'en-US', + 'input_string': '2024-03-17T00:00:00Z', + 'options': { + 'timeZone': 'America/Los_Angeles', + 'dateStyle': 'full', + 'timeStyle': 'full', + 'dateTimeFormatType': 'standard', + 'calendar': 'gregory', + }, + 'tz_offset_secs': -25200.0, + 'original_input': '2024-03-16T17:00-07:00[America/Los_Angeles]', + }; + final outputLine = testDateTimeFmt(jsonEncode(inputLine)); + final decoded = jsonDecode(outputLine) as Map; + expect(decoded['result'], contains('Saturday, March 16, 2024')); + expect(decoded['result'], contains('Pacific Daylight Time')); + }); + testWithFormatting('decimal format compact', () { final input = { 'label': '0730', diff --git a/generateDataAndRun.sh b/generateDataAndRun.sh index c5d1e42e..98de0bcd 100755 --- a/generateDataAndRun.sh +++ b/generateDataAndRun.sh @@ -12,9 +12,9 @@ logrotate -s logrotate.state logrotate.conf (while true; do echo "[$(date +%T)] --- VITALS ---" # RAM usage - echo "Memory: $(free -h | awk 'NR==2{print $3 \" / \" $2}')" + echo "Memory: $(free -h | awk 'NR==2{print $3 " / " $2}')" # Disk usage for the current workspace - echo "Disk: $(df -h . | awk 'NR==2{print $3 \" used / \" $4 \" avail (\" $5 \")\"}')" + echo "Disk: $(df -h . | awk 'NR==2{print $3 " used / " $4 " avail (" $5 ")"}')" # CPU Load echo "CPU Load: $(cut -d' ' -f1-3 /proc/loadavg)" echo "------------------------" @@ -36,7 +36,7 @@ esac echo "This machine is: ${machine}" # Ensure that ICU4C binaries have been downloaded locally -if [[ ! -d gh-cache ]] +if [ ! -d gh-cache ] || [ -z "$(ls -A gh-cache 2>/dev/null)" ] then bash setup_${machine}.sh fi diff --git a/run_config.json b/run_config.json index 3014f6a3..7e4edd69 100644 --- a/run_config.json +++ b/run_config.json @@ -279,7 +279,29 @@ "number_fmt", "lang_names", "plural_rules", - "list_fmt" + "list_fmt", + "likely_subtags" + ], + "per_execution": 10000 + } + }, + { + "prereq": { + "name": "nvm 26.3.0, icu78.3", + "version": "26.3.0", + "command": "nvm install 26.3.0;nvm use 26.3.0 --silent" + }, + "run": { + "icu_version": "icu78", + "exec": "dart_web", + "test_type": [ + "collation", + "datetime_fmt", + "number_fmt", + "lang_names", + "plural_rules", + "list_fmt", + "likely_subtags" ], "per_execution": 10000 } @@ -299,7 +321,8 @@ "number_fmt", "lang_names", "plural_rules", - "list_fmt" + "list_fmt", + "likely_subtags" ], "per_execution": 10000 } @@ -319,7 +342,8 @@ "number_fmt", "lang_names", "plural_rules", - "list_fmt" + "list_fmt", + "likely_subtags" ], "per_execution": 10000 } @@ -339,7 +363,8 @@ "number_fmt", "lang_names", "plural_rules", - "list_fmt" + "list_fmt", + "likely_subtags" ], "per_execution": 10000 } @@ -359,7 +384,8 @@ "number_fmt", "lang_names", "plural_rules", - "list_fmt" + "list_fmt", + "likely_subtags" ], "per_execution": 10000 } @@ -379,7 +405,8 @@ "number_fmt", "lang_names", "plural_rules", - "list_fmt" + "list_fmt", + "likely_subtags" ], "per_execution": 10000 } diff --git a/setup_linux.sh b/setup_linux.sh index 38d5fec6..d366ff00 100755 --- a/setup_linux.sh +++ b/setup_linux.sh @@ -3,6 +3,13 @@ # If there's a problem, exit with error status set -e +# install git if not already installed +if ! command -v git &> /dev/null +then + sudo apt-get update + sudo apt-get install -y git +fi + # install libjson-c-dev if not already installed dpkg --list | grep libjson-c-dev || error_code=$? if [[ $error_code -ne 0 ]] diff --git a/testgen/testdata_gen.py b/testgen/testdata_gen.py index 9f276122..20ada7bd 100644 --- a/testgen/testdata_gen.py +++ b/testgen/testdata_gen.py @@ -10,7 +10,11 @@ from generators.datetime_fmt import DateTimeFmtGenerator from generators.localeDisplayNames import LocaleNamesGenerator from generators.likely_subtags import LikelySubtagsGenerator -from generators.message_fmt2 import MessageFmt2Generator +try: + from generators.message_fmt2 import MessageFmt2Generator + has_message_fmt2 = True +except ImportError: + has_message_fmt2 = False from generators.list_fmt import ListFmtGenerator from generators.number_fmt import NumberFmtGenerator from generators.plurals import PluralGenerator @@ -95,8 +99,11 @@ def generate_versioned_data(version_info): generator.process_test_data() if TestType.MESSAGE_FMT2 in args.test_types: - generator = MessageFmt2Generator(icu_version, args.run_limit) - generator.process_test_data() + if not has_message_fmt2: + logger.warning("MessageFmt2Generator is not available (missing jsonschema?). Skipping.") + else: + generator = MessageFmt2Generator(icu_version, args.run_limit) + generator.process_test_data() if TestType.NUMBER_FMT in args.test_types: generator = NumberFmtGenerator(icu_version, args.run_limit) diff --git a/verifier/verifier.py b/verifier/verifier.py index 41444e85..5daefc10 100644 --- a/verifier/verifier.py +++ b/verifier/verifier.py @@ -227,7 +227,7 @@ def setup_verify_plans(self): # Verify plans in parallel def parallel_verify_data_results(self): if not self.options.run_serial: - num_processors = mp.cpu_count() + num_processors = min(2, mp.cpu_count()) verify_plans = self.verify_plans logger.info('JSON validation: %s processors for %s plans', num_processors, len(verify_plans))