Skip to content

Commit a6c12c1

Browse files
committed
test: split cases in loop
1 parent a16e14f commit a6c12c1

2 files changed

Lines changed: 34 additions & 34 deletions

File tree

packages/sh/test/__snapshots__/fixtures.spec.ts.snap

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3-
exports[`parser and printer > should format all fixtures > .dockerignore 1`] = `
3+
exports[`parser and printer > should format .dockerignore fixtures > .dockerignore 1`] = `
44
"*.less.json
55
*.log
66
*.tsbuildinfo
@@ -11,12 +11,12 @@ node_modules
1111
"
1212
`;
1313

14-
exports[`parser and printer > should format all fixtures > .nvmrc 1`] = `
14+
exports[`parser and printer > should format .nvmrc fixtures > .nvmrc 1`] = `
1515
"v1.2.3
1616
"
1717
`;
1818

19-
exports[`parser and printer > should format all fixtures > .properties 1`] = `
19+
exports[`parser and printer > should format .properties fixtures > .properties 1`] = `
2020
"# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2121
# yarn lockfile v1
2222
@@ -26,7 +26,7 @@ username jounqin
2626
"
2727
`;
2828

29-
exports[`parser and printer > should format all fixtures > 133.sh 1`] = `
29+
exports[`parser and printer > should format 133.sh fixtures > 133.sh 1`] = `
3030
"#!/usr/bin/env bash
3131
3232
set -euo pipefail
@@ -218,7 +218,7 @@ main "$@"
218218
"
219219
`;
220220
221-
exports[`parser and printer > should format all fixtures > 146.ini 1`] = `
221+
exports[`parser and printer > should format 146.ini fixtures > 146.ini 1`] = `
222222
"# site-packages is here to help vscode mypy integration getting confused
223223
224224
# 3rd party ignores
@@ -257,7 +257,7 @@ ignore_missing_imports = True
257257
"
258258
`;
259259
260-
exports[`parser and printer > should format all fixtures > 147.cfg 1`] = `
260+
exports[`parser and printer > should format 147.cfg fixtures > 147.cfg 1`] = `
261261
"LABEL org.opencontainers.image.authors="= Ansible by Red Hat"
262262
263263
@@ -279,7 +279,7 @@ exports[`parser and printer > should format all fixtures > 147.cfg 1`] = `
279279
# indention is a typo in ruamel.yaml's API "
280280
`;
281281
282-
exports[`parser and printer > should format all fixtures > 148.ini 1`] = `
282+
exports[`parser and printer > should format 148.ini fixtures > 148.ini 1`] = `
283283
"# spell-checker:ignore filterwarnings norecursedirs optionflags
284284
# do not add options here as this will likely break either console runs or IDE
285285
# integration like vscode or pycharm
@@ -308,7 +308,7 @@ exports[`parser and printer > should format all fixtures > 148.ini 1`] = `
308308
"
309309
`;
310310
311-
exports[`parser and printer > should format all fixtures > 162.sh 1`] = `
311+
exports[`parser and printer > should format 162.sh fixtures > 162.sh 1`] = `
312312
"#!/usr/bin/env bash
313313
314314
{ # this ensures the entire script is downloaded #
@@ -790,7 +790,7 @@ exports[`parser and printer > should format all fixtures > 162.sh 1`] = `
790790
"
791791
`;
792792
793-
exports[`parser and printer > should format all fixtures > 182.sh 1`] = `
793+
exports[`parser and printer > should format 182.sh fixtures > 182.sh 1`] = `
794794
"#!/usr/bin/env bash
795795
set -euo pipefail
796796
@@ -846,7 +846,7 @@ fi
846846
"
847847
`;
848848
849-
exports[`parser and printer > should format all fixtures > 191.sh 1`] = `
849+
exports[`parser and printer > should format 191.sh fixtures > 191.sh 1`] = `
850850
"#!/bin/sh
851851
852852
set -eu
@@ -926,29 +926,29 @@ esac
926926
"
927927
`;
928928
929-
exports[`parser and printer > should format all fixtures > 278.Dockerfile 1`] = `
929+
exports[`parser and printer > should format 278.Dockerfile fixtures > 278.Dockerfile 1`] = `
930930
"FROM ubuntu
931931
932932
RUN (cd out && ls)"
933933
`;
934934
935-
exports[`parser and printer > should format all fixtures > 278.Dockerfile 2`] = `
935+
exports[`parser and printer > should format 278.Dockerfile fixtures > 278.Dockerfile 2`] = `
936936
"FROM ubuntu
937937
938938
RUN (cd out && ls)"
939939
`;
940940
941-
exports[`parser and printer > should format all fixtures > 292.Dockerfile 1`] = `
941+
exports[`parser and printer > should format 292.Dockerfile fixtures > 292.Dockerfile 1`] = `
942942
"FROM node:20.9.0-alpine
943943
RUN if [[ x$LATEST_NPM = xtrue ]]; then yarn global add npm@latest; fi"
944944
`;
945945
946-
exports[`parser and printer > should format all fixtures > 292.Dockerfile 2`] = `
946+
exports[`parser and printer > should format 292.Dockerfile fixtures > 292.Dockerfile 2`] = `
947947
"FROM node:20.9.0-alpine
948948
RUN if [[ x$LATEST_NPM = xtrue ]]; then yarn global add npm@latest; fi"
949949
`;
950950
951-
exports[`parser and printer > should format all fixtures > 376.Dockerfile 1`] = `
951+
exports[`parser and printer > should format 376.Dockerfile fixtures > 376.Dockerfile 1`] = `
952952
"FROM debian:12.6-slim
953953
954954
RUN set -eux
@@ -970,7 +970,7 @@ EOF
970970
"
971971
`;
972972
973-
exports[`parser and printer > should format all fixtures > 376.Dockerfile 2`] = `
973+
exports[`parser and printer > should format 376.Dockerfile fixtures > 376.Dockerfile 2`] = `
974974
"FROM debian:12.6-slim
975975
976976
RUN set -eux; for x in {1..3}; do echo 'foo'; echo 'bar'; echo "$x"; done
@@ -985,11 +985,11 @@ done
985985
EOF"
986986
`;
987987
988-
exports[`parser and printer > should format all fixtures > 384.Dockerfile 1`] = `"LABEL org.opencontainers.image.authors="Jean Luc Picard <picardj@starfleet.gov>""`;
988+
exports[`parser and printer > should format 384.Dockerfile fixtures > 384.Dockerfile 1`] = `"LABEL org.opencontainers.image.authors="Jean Luc Picard <picardj@starfleet.gov>""`;
989989
990-
exports[`parser and printer > should format all fixtures > 384.Dockerfile 2`] = `"LABEL org.opencontainers.image.authors="Jean Luc Picard <picardj@starfleet.gov>""`;
990+
exports[`parser and printer > should format 384.Dockerfile fixtures > 384.Dockerfile 2`] = `"LABEL org.opencontainers.image.authors="Jean Luc Picard <picardj@starfleet.gov>""`;
991991
992-
exports[`parser and printer > should format all fixtures > 398.Dockerfile 1`] = `
992+
exports[`parser and printer > should format 398.Dockerfile fixtures > 398.Dockerfile 1`] = `
993993
"ENV a=1 \\
994994
b=2
995995
# comment
@@ -1000,7 +1000,7 @@ e=5
10001000
"
10011001
`;
10021002
1003-
exports[`parser and printer > should format all fixtures > 398.Dockerfile 2`] = `
1003+
exports[`parser and printer > should format 398.Dockerfile fixtures > 398.Dockerfile 2`] = `
10041004
"ENV a=1 \\
10051005
b=2 \\
10061006
# comment
@@ -1010,7 +1010,7 @@ exports[`parser and printer > should format all fixtures > 398.Dockerfile 2`] =
10101010
e=5"
10111011
`;
10121012
1013-
exports[`parser and printer > should format all fixtures > Dockerfile 1`] = `
1013+
exports[`parser and printer > should format Dockerfile fixtures > Dockerfile 1`] = `
10141014
"FROM node:lts-alpine as builder
10151015
10161016
# 安装与编译代码
@@ -1027,7 +1027,7 @@ EXPOSE 2015
10271027
"
10281028
`;
10291029
1030-
exports[`parser and printer > should format all fixtures > Dockerfile 2`] = `
1030+
exports[`parser and printer > should format Dockerfile fixtures > Dockerfile 2`] = `
10311031
"FROM node:lts-alpine as builder
10321032
10331033
# 安装与编译代码
@@ -1043,7 +1043,7 @@ COPY --from=builder /app/packages/ufc-host-app/build /srv
10431043
EXPOSE 2015"
10441044
`;
10451045
1046-
exports[`parser and printer > should format all fixtures > hosts 1`] = `
1046+
exports[`parser and printer > should format hosts fixtures > hosts 1`] = `
10471047
"##
10481048
# Host Database
10491049
#
@@ -1060,21 +1060,21 @@ exports[`parser and printer > should format all fixtures > hosts 1`] = `
10601060
"
10611061
`;
10621062
1063-
exports[`parser and printer > should format all fixtures > jvm.options 1`] = `
1063+
exports[`parser and printer > should format jvm.options fixtures > jvm.options 1`] = `
10641064
"# this is a comment
10651065
-mx2048m -XX:MaxPermSize=2048m -Drebel.spring_plugin=true -Drebel.hibernate_plugin=true
10661066
10671067
idea.cycle.buffer.size = 1024
10681068
"
10691069
`;
10701070
1071-
exports[`parser and printer > should format all fixtures > no-ext 1`] = `
1071+
exports[`parser and printer > should format no-ext fixtures > no-ext 1`] = `
10721072
"#/usr/bin/env sh
10731073
echo 'foo'
10741074
"
10751075
`;
10761076
1077-
exports[`parser and printer > should format all fixtures > shell.sh 1`] = `
1077+
exports[`parser and printer > should format shell.sh fixtures > shell.sh 1`] = `
10781078
"#!/bin/bash
10791079
NAME= "ufc-web-client"
10801080

packages/sh/test/fixtures.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import * as sh from 'prettier-plugin-sh'
88
const _dirname = import.meta.dirname
99

1010
describe('parser and printer', () => {
11-
it('should format all fixtures', async () => {
12-
const fixtures = path.resolve(_dirname, 'fixtures')
13-
for (const relativeFilepath of fs.readdirSync(fixtures)) {
14-
const filepath = path.resolve(fixtures, relativeFilepath)
15-
const input = fs.readFileSync(filepath, 'utf8')
11+
const fixtures = path.resolve(_dirname, 'fixtures')
12+
for (const relativeFilepath of fs.readdirSync(fixtures)) {
13+
const filepath = path.resolve(fixtures, relativeFilepath)
14+
const input = fs.readFileSync(filepath, 'utf8')
1615

16+
it(`should format ${relativeFilepath} fixtures`, async () => {
1717
try {
1818
const output = await format(input, {
1919
filepath,
@@ -31,7 +31,7 @@ describe('parser and printer', () => {
3131
const filename = path.basename(filepath)
3232

3333
if (filename !== 'Dockerfile' && !filename.endsWith('.Dockerfile')) {
34-
continue
34+
return
3535
}
3636

3737
try {
@@ -47,6 +47,6 @@ describe('parser and printer', () => {
4747
relativeFilepath,
4848
)
4949
}
50-
}
51-
})
50+
})
51+
}
5252
})

0 commit comments

Comments
 (0)