Skip to content

Commit bf44fb3

Browse files
committed
feat: add tests for action-level skipCommands
1 parent a38d366 commit bf44fb3

2 files changed

Lines changed: 322 additions & 1 deletion

File tree

__snapshots__/find-python-projects.test.js.snap

Lines changed: 301 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,307 @@ exports[`find-python-projects Exports keys as instructed 1`] = `
4848
}
4949
`;
5050

51+
exports[`find-python-projects doesn't export commands we should globally skip 1`] = `
52+
{
53+
"paths": [
54+
"test-fixtures/multi-project/project-1/pyproject.toml",
55+
"test-fixtures/multi-project/project-2/pyproject.toml",
56+
"test-fixtures/multi-project/project-4/pyproject.toml",
57+
"test-fixtures/multi-project/project-5/pyproject.toml",
58+
"test-fixtures/multi-project/project-6/pyproject.toml",
59+
],
60+
"projects": [
61+
{
62+
"buildBackend": "poetry.core.masonry.api",
63+
"commands": {
64+
"install": "poetry install",
65+
},
66+
"directory": "test-fixtures/multi-project/project-1",
67+
"exports": {},
68+
"name": "sub-project-1",
69+
"path": "test-fixtures/multi-project/project-1/pyproject.toml",
70+
"pythonVersion": "^3.9",
71+
},
72+
{
73+
"buildBackend": "poetry.core.masonry.api",
74+
"commands": {
75+
"install": "poetry install",
76+
"package": "poetry bundle venv .package/",
77+
"something-arbitrary": "echo 'Example of arbitrary shell command'",
78+
},
79+
"directory": "test-fixtures/multi-project/project-2",
80+
"exports": {},
81+
"name": "sub-project-2",
82+
"path": "test-fixtures/multi-project/project-2/pyproject.toml",
83+
"pythonVersion": "^3.9",
84+
},
85+
{
86+
"commands": {
87+
"install": null,
88+
},
89+
"directory": "test-fixtures/multi-project/project-4",
90+
"exports": {},
91+
"name": "sub-project-4",
92+
"path": "test-fixtures/multi-project/project-4/pyproject.toml",
93+
"pythonVersion": "^3.9",
94+
},
95+
{
96+
"buildBackend": "pdm.backend",
97+
"commands": {
98+
"install": "pdm install",
99+
},
100+
"directory": "test-fixtures/multi-project/project-5",
101+
"exports": {},
102+
"name": "project-5",
103+
"path": "test-fixtures/multi-project/project-5/pyproject.toml",
104+
"pythonVersion": "==3.12.*",
105+
},
106+
{
107+
"buildBackend": "poetry.core.masonry.api",
108+
"commands": {
109+
"install": "poetry install",
110+
},
111+
"directory": "test-fixtures/multi-project/project-6",
112+
"exports": {},
113+
"name": "sub-project-6",
114+
"path": "test-fixtures/multi-project/project-6/pyproject.toml",
115+
"pythonVersion": "^3.9",
116+
},
117+
],
118+
"projects-by-command": {
119+
"install": [
120+
{
121+
"buildBackend": "poetry.core.masonry.api",
122+
"commands": {
123+
"install": "poetry install",
124+
},
125+
"directory": "test-fixtures/multi-project/project-1",
126+
"exports": {},
127+
"name": "sub-project-1",
128+
"path": "test-fixtures/multi-project/project-1/pyproject.toml",
129+
"pythonVersion": "^3.9",
130+
},
131+
{
132+
"buildBackend": "poetry.core.masonry.api",
133+
"commands": {
134+
"install": "poetry install",
135+
"package": "poetry bundle venv .package/",
136+
"something-arbitrary": "echo 'Example of arbitrary shell command'",
137+
},
138+
"directory": "test-fixtures/multi-project/project-2",
139+
"exports": {},
140+
"name": "sub-project-2",
141+
"path": "test-fixtures/multi-project/project-2/pyproject.toml",
142+
"pythonVersion": "^3.9",
143+
},
144+
{
145+
"buildBackend": "pdm.backend",
146+
"commands": {
147+
"install": "pdm install",
148+
},
149+
"directory": "test-fixtures/multi-project/project-5",
150+
"exports": {},
151+
"name": "project-5",
152+
"path": "test-fixtures/multi-project/project-5/pyproject.toml",
153+
"pythonVersion": "==3.12.*",
154+
},
155+
{
156+
"buildBackend": "poetry.core.masonry.api",
157+
"commands": {
158+
"install": "poetry install",
159+
},
160+
"directory": "test-fixtures/multi-project/project-6",
161+
"exports": {},
162+
"name": "sub-project-6",
163+
"path": "test-fixtures/multi-project/project-6/pyproject.toml",
164+
"pythonVersion": "^3.9",
165+
},
166+
],
167+
"package": [
168+
{
169+
"buildBackend": "poetry.core.masonry.api",
170+
"commands": {
171+
"install": "poetry install",
172+
"package": "poetry bundle venv .package/",
173+
"something-arbitrary": "echo 'Example of arbitrary shell command'",
174+
},
175+
"directory": "test-fixtures/multi-project/project-2",
176+
"exports": {},
177+
"name": "sub-project-2",
178+
"path": "test-fixtures/multi-project/project-2/pyproject.toml",
179+
"pythonVersion": "^3.9",
180+
},
181+
],
182+
"something-arbitrary": [
183+
{
184+
"buildBackend": "poetry.core.masonry.api",
185+
"commands": {
186+
"install": "poetry install",
187+
"package": "poetry bundle venv .package/",
188+
"something-arbitrary": "echo 'Example of arbitrary shell command'",
189+
},
190+
"directory": "test-fixtures/multi-project/project-2",
191+
"exports": {},
192+
"name": "sub-project-2",
193+
"path": "test-fixtures/multi-project/project-2/pyproject.toml",
194+
"pythonVersion": "^3.9",
195+
},
196+
],
197+
},
198+
}
199+
`;
200+
201+
exports[`find-python-projects doesn't export commands we should skip for certain projects 1`] = `
202+
{
203+
"paths": [
204+
"test-fixtures/multi-project/project-1/pyproject.toml",
205+
"test-fixtures/multi-project/project-2/pyproject.toml",
206+
"test-fixtures/multi-project/project-4/pyproject.toml",
207+
"test-fixtures/multi-project/project-5/pyproject.toml",
208+
"test-fixtures/multi-project/project-6/pyproject.toml",
209+
],
210+
"projects": [
211+
{
212+
"buildBackend": "poetry.core.masonry.api",
213+
"commands": {
214+
"install": "poetry install",
215+
},
216+
"directory": "test-fixtures/multi-project/project-1",
217+
"exports": {},
218+
"name": "sub-project-1",
219+
"path": "test-fixtures/multi-project/project-1/pyproject.toml",
220+
"pythonVersion": "^3.9",
221+
},
222+
{
223+
"buildBackend": "poetry.core.masonry.api",
224+
"commands": {
225+
"install": "poetry install",
226+
"package": "poetry bundle venv .package/",
227+
"test": "poetry run pytest",
228+
},
229+
"directory": "test-fixtures/multi-project/project-2",
230+
"exports": {},
231+
"name": "sub-project-2",
232+
"path": "test-fixtures/multi-project/project-2/pyproject.toml",
233+
"pythonVersion": "^3.9",
234+
},
235+
{
236+
"commands": {
237+
"install": null,
238+
},
239+
"directory": "test-fixtures/multi-project/project-4",
240+
"exports": {},
241+
"name": "sub-project-4",
242+
"path": "test-fixtures/multi-project/project-4/pyproject.toml",
243+
"pythonVersion": "^3.9",
244+
},
245+
{
246+
"buildBackend": "pdm.backend",
247+
"commands": {},
248+
"directory": "test-fixtures/multi-project/project-5",
249+
"exports": {},
250+
"name": "project-5",
251+
"path": "test-fixtures/multi-project/project-5/pyproject.toml",
252+
"pythonVersion": "==3.12.*",
253+
},
254+
{
255+
"buildBackend": "poetry.core.masonry.api",
256+
"commands": {
257+
"install": "poetry install",
258+
"test": "poe test",
259+
},
260+
"directory": "test-fixtures/multi-project/project-6",
261+
"exports": {},
262+
"name": "sub-project-6",
263+
"path": "test-fixtures/multi-project/project-6/pyproject.toml",
264+
"pythonVersion": "^3.9",
265+
},
266+
],
267+
"projects-by-command": {
268+
"install": [
269+
{
270+
"buildBackend": "poetry.core.masonry.api",
271+
"commands": {
272+
"install": "poetry install",
273+
},
274+
"directory": "test-fixtures/multi-project/project-1",
275+
"exports": {},
276+
"name": "sub-project-1",
277+
"path": "test-fixtures/multi-project/project-1/pyproject.toml",
278+
"pythonVersion": "^3.9",
279+
},
280+
{
281+
"buildBackend": "poetry.core.masonry.api",
282+
"commands": {
283+
"install": "poetry install",
284+
"package": "poetry bundle venv .package/",
285+
"test": "poetry run pytest",
286+
},
287+
"directory": "test-fixtures/multi-project/project-2",
288+
"exports": {},
289+
"name": "sub-project-2",
290+
"path": "test-fixtures/multi-project/project-2/pyproject.toml",
291+
"pythonVersion": "^3.9",
292+
},
293+
{
294+
"buildBackend": "poetry.core.masonry.api",
295+
"commands": {
296+
"install": "poetry install",
297+
"test": "poe test",
298+
},
299+
"directory": "test-fixtures/multi-project/project-6",
300+
"exports": {},
301+
"name": "sub-project-6",
302+
"path": "test-fixtures/multi-project/project-6/pyproject.toml",
303+
"pythonVersion": "^3.9",
304+
},
305+
],
306+
"package": [
307+
{
308+
"buildBackend": "poetry.core.masonry.api",
309+
"commands": {
310+
"install": "poetry install",
311+
"package": "poetry bundle venv .package/",
312+
"test": "poetry run pytest",
313+
},
314+
"directory": "test-fixtures/multi-project/project-2",
315+
"exports": {},
316+
"name": "sub-project-2",
317+
"path": "test-fixtures/multi-project/project-2/pyproject.toml",
318+
"pythonVersion": "^3.9",
319+
},
320+
],
321+
"test": [
322+
{
323+
"buildBackend": "poetry.core.masonry.api",
324+
"commands": {
325+
"install": "poetry install",
326+
"package": "poetry bundle venv .package/",
327+
"test": "poetry run pytest",
328+
},
329+
"directory": "test-fixtures/multi-project/project-2",
330+
"exports": {},
331+
"name": "sub-project-2",
332+
"path": "test-fixtures/multi-project/project-2/pyproject.toml",
333+
"pythonVersion": "^3.9",
334+
},
335+
{
336+
"buildBackend": "poetry.core.masonry.api",
337+
"commands": {
338+
"install": "poetry install",
339+
"test": "poe test",
340+
},
341+
"directory": "test-fixtures/multi-project/project-6",
342+
"exports": {},
343+
"name": "sub-project-6",
344+
"path": "test-fixtures/multi-project/project-6/pyproject.toml",
345+
"pythonVersion": "^3.9",
346+
},
347+
],
348+
},
349+
}
350+
`;
351+
51352
exports[`find-python-projects finds projects 1`] = `
52353
{
53354
"paths": [

find-python-projects.test.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe("find-python-projects", () => {
1111

1212
const inputsDefaults = {
1313
"additional-export-paths": "",
14-
skipCommands: "",
14+
"exclude-commands": "",
1515
};
1616
let inputs = {};
1717
let outputs = {};
@@ -53,6 +53,26 @@ describe("find-python-projects", () => {
5353
expect(deserializeJsonValues(outputs)).toMatchSnapshot();
5454
expect(infoMock).toHaveBeenCalled();
5555
});
56+
57+
it("doesn't export commands we should globally skip", async () => {
58+
inputs["root-dir"] = "test-fixtures/multi-project";
59+
inputs["exclude-commands"] = "test";
60+
await run();
61+
expect(deserializeJsonValues(outputs)).toMatchSnapshot();
62+
expect(infoMock).toHaveBeenCalled();
63+
});
64+
65+
it("doesn't export commands we should skip for certain projects", async () => {
66+
inputs["root-dir"] = "test-fixtures/multi-project";
67+
inputs["exclude-commands"] = `
68+
project=sub-project-2,command=something-arbitrary
69+
project=project-5,command=test
70+
project=project-5,command=install
71+
`;
72+
await run();
73+
expect(deserializeJsonValues(outputs)).toMatchSnapshot();
74+
expect(infoMock).toHaveBeenCalled();
75+
});
5676
});
5777

5878
function deserializeJsonValues(obj) {

0 commit comments

Comments
 (0)