-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathuv.test.ts
More file actions
78 lines (67 loc) · 3.02 KB
/
uv.test.ts
File metadata and controls
78 lines (67 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { detectUnavailablePlatform } from '../uv.js';
import { describe, expect, it } from 'vitest';
function result(stdout: string, stderr = '') {
return { code: 1, stdout, stderr, signal: null as NodeJS.Signals | null };
}
describe('detectUnavailablePlatform', () => {
it('returns null when output has no platform hints', () => {
expect(detectUnavailablePlatform(result('Some generic error'))).toBeNull();
});
it('detects platform hint with manylinux tokens', () => {
const out = 'error: No matching distribution\nplatforms: manylinux2014_aarch64, manylinux_2_28_aarch64\nhelp: ...';
const issue = detectUnavailablePlatform(result(out));
expect(issue).not.toBeNull();
expect(issue!.platforms).toBeDefined();
expect(issue!.platforms!.length).toBeGreaterThan(0);
expect(issue!.platforms!.some(p => p.includes('manylinux'))).toBe(true);
});
it('detects "no wheels with a matching platform tag" message', () => {
const out = 'error: has no wheels with a matching platform tag';
const issue = detectUnavailablePlatform(result(out));
expect(issue).not.toBeNull();
expect(issue!.message).toContain('wheels');
});
it('detects "no compatible wheels found" message', () => {
const issue = detectUnavailablePlatform(result('no compatible wheels found for package foo'));
expect(issue).not.toBeNull();
});
it('detects "no compatible tags found" message', () => {
const issue = detectUnavailablePlatform(result('no compatible tags found'));
expect(issue).not.toBeNull();
});
it('checks stderr as well as stdout', () => {
const issue = detectUnavailablePlatform(result('', 'has no wheels with a matching platform tag'));
expect(issue).not.toBeNull();
});
it('returns message with context lines around the match', () => {
const lines = [
'line 1',
'line 2',
'line 3',
'error: has no wheels with a matching platform tag',
'line 5',
'line 6',
'line 7',
];
const issue = detectUnavailablePlatform(result(lines.join('\n')));
expect(issue).not.toBeNull();
// Message should include context lines around the match
expect(issue!.message).toContain('has no wheels');
});
it('detects "no wheels with a matching Python ABI tag" message (e.g. cp314)', () => {
const out = 'numpy==2.4.4 has no wheels with a matching Python ABI tag (e.g., `cp314`)';
const issue = detectUnavailablePlatform(result(out));
expect(issue).not.toBeNull();
expect(issue!.message).toContain('cp314');
});
it('detects "has no usable wheels" message', () => {
const out = 'numpy>=1.10.4 has no usable wheels, we can conclude that numpy>=1.10.4 cannot be used.';
const issue = detectUnavailablePlatform(result(out));
expect(issue).not.toBeNull();
expect(issue!.message).toContain('usable wheels');
});
it('returns null for successful output', () => {
const out = 'Successfully installed package-1.0.0\nAll done!';
expect(detectUnavailablePlatform({ code: 0, stdout: out, stderr: '', signal: null })).toBeNull();
});
});