-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix @formatjs/icu-messageformat-parser test
- Loading branch information
long.ho
committed
Sep 6, 2022
1 parent
16c943c
commit 2b26b36
Showing
112 changed files
with
96 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files") | ||
load("//tools:index.bzl", "generate_src_file") | ||
load("@npm//:defs.bzl", "npm_link_all_packages") | ||
|
||
npm_link_all_packages(name = "node_modules") | ||
|
||
TEST_CASES = glob(["test_cases/*"]) | ||
|
||
# [ts_script( | ||
# name = "gen_parser_test_%s" % f.split("/")[-1], | ||
# outs = ["%s.tmp" % f.split("/")[-1]], | ||
# args = [ | ||
# "--input", | ||
# f | ||
# ], | ||
# data = [ | ||
# ":node_modules/@formatjs/icu-messageformat-parser", | ||
# "//:node_modules/lodash", | ||
# f | ||
# ], | ||
# entry_point = "run-parser.ts", | ||
# ) for f in TEST_CASES] | ||
|
||
[generate_src_file( | ||
name = "gen_parser_test_%s" % f.split("/")[-1], | ||
src = f, | ||
data = [ | ||
":node_modules/@formatjs/icu-messageformat-parser", | ||
"//:node_modules/lodash", | ||
f | ||
], | ||
args = [ | ||
"--input %s/%s" % (package_name(),f), | ||
], | ||
entry_point = "run-parser.ts", | ||
) for f in TEST_CASES] |
5 changes: 5 additions & 0 deletions
5
packages/icu-messageformat-parser/integration-tests/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"@formatjs/icu-messageformat-parser": "workspace:*" | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
packages/icu-messageformat-parser/integration-tests/run-parser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {_Parser} from '@formatjs/icu-messageformat-parser' | ||
import fs from 'fs' | ||
import minimist from 'minimist' | ||
|
||
interface Args extends minimist.ParsedArgs { | ||
input: string | ||
out: string | ||
} | ||
|
||
function run({input, out}: Args) { | ||
console.log(__dirname) | ||
const sections = fs.readFileSync(input, 'utf-8').split('\n---\n') | ||
const message = sections[0] | ||
const snapshotOptions = JSON.parse(sections[1]) | ||
const options = {...snapshotOptions} | ||
// Note: allow locale to be specified via an identifier. | ||
if (options.locale) { | ||
options.locale = new Intl.Locale(options.locale) | ||
} | ||
|
||
const parsed = new _Parser(message, options).parse() | ||
|
||
// If the mismatch is intentional, use `UPDATE_SNAPSHOT=1` env var | ||
// with bazel run to update the snapshot. | ||
fs.writeFileSync( | ||
out, | ||
[ | ||
message, | ||
JSON.stringify(snapshotOptions, null, 2), | ||
JSON.stringify(parsed, null, 2), | ||
].join('\n---\n'), | ||
'utf-8' | ||
) | ||
} | ||
|
||
if (require.main === module) { | ||
run(minimist<Args>(process.argv.slice(2))) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,4 +46,4 @@ | |
} | ||
], | ||
"err": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,4 +46,4 @@ | |
} | ||
], | ||
"err": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,4 @@ | |
} | ||
], | ||
"err": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,4 @@ | |
} | ||
], | ||
"err": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,4 @@ | |
} | ||
], | ||
"err": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,4 @@ | |
} | ||
], | ||
"err": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,4 @@ | |
} | ||
], | ||
"err": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,4 @@ | |
} | ||
], | ||
"err": null | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.