|
1 | | -import io = require('@actions/io'); |
2 | | -import fs = require('fs'); |
3 | | -import path = require('path'); |
4 | | - |
5 | | -const toolDir = path.join( |
6 | | - __dirname, |
7 | | - 'runner', |
8 | | - path.join( |
9 | | - Math.random() |
10 | | - .toString(36) |
11 | | - .substring(7) |
12 | | - ), |
13 | | - 'tools' |
14 | | -); |
15 | | -const tempDir = path.join( |
16 | | - __dirname, |
17 | | - 'runner', |
18 | | - path.join( |
19 | | - Math.random() |
20 | | - .toString(36) |
21 | | - .substring(7) |
22 | | - ), |
23 | | - 'temp' |
24 | | -); |
25 | | - |
26 | | -process.env['RUNNER_TOOL_CACHE'] = toolDir; |
27 | | -process.env['RUNNER_TEMP'] = tempDir; |
28 | | - |
29 | | -import * as finder from '../src/find-python'; |
30 | | - |
31 | | -describe('Finder tests', () => { |
32 | | - it('Finds Python if it is installed', async () => { |
33 | | - const pythonDir: string = path.join(toolDir, 'Python', '3.0.0', 'x64'); |
34 | | - await io.mkdirP(pythonDir); |
35 | | - fs.writeFileSync(`${pythonDir}.complete`, 'hello'); |
36 | | - // This will throw if it doesn't find it in the cache (because no such version exists) |
37 | | - await finder.findPythonVersion('3.x', 'x64'); |
38 | | - }); |
39 | | - |
40 | | - it('Errors if Python is not installed', async () => { |
41 | | - // This will throw if it doesn't find it in the cache (because no such version exists) |
42 | | - let thrown = false; |
43 | | - try { |
44 | | - await finder.findPythonVersion('3.300000', 'x64'); |
45 | | - } catch { |
46 | | - thrown = true; |
47 | | - } |
48 | | - expect(thrown).toBeTruthy(); |
49 | | - }); |
50 | | - |
51 | | - it('Finds PyPy if it is installed', async () => { |
52 | | - const pythonDir: string = path.join(toolDir, 'PyPy', '2.0.0', 'x64'); |
53 | | - await io.mkdirP(pythonDir); |
54 | | - fs.writeFileSync(`${pythonDir}.complete`, 'hello'); |
55 | | - // This will throw if it doesn't find it in the cache (because no such version exists) |
56 | | - await finder.findPythonVersion('pypy2', 'x64'); |
57 | | - }); |
58 | | -}); |
| 1 | +import io = require('@actions/io'); |
| 2 | +import fs = require('fs'); |
| 3 | +import path = require('path'); |
| 4 | + |
| 5 | +const toolDir = path.join( |
| 6 | + __dirname, |
| 7 | + 'runner', |
| 8 | + path.join( |
| 9 | + Math.random() |
| 10 | + .toString(36) |
| 11 | + .substring(7) |
| 12 | + ), |
| 13 | + 'tools' |
| 14 | +); |
| 15 | +const tempDir = path.join( |
| 16 | + __dirname, |
| 17 | + 'runner', |
| 18 | + path.join( |
| 19 | + Math.random() |
| 20 | + .toString(36) |
| 21 | + .substring(7) |
| 22 | + ), |
| 23 | + 'temp' |
| 24 | +); |
| 25 | + |
| 26 | +process.env['RUNNER_TOOL_CACHE'] = toolDir; |
| 27 | +process.env['RUNNER_TEMP'] = tempDir; |
| 28 | + |
| 29 | +import * as finder from '../src/find-python'; |
| 30 | + |
| 31 | +describe('Finder tests', () => { |
| 32 | + it('Finds Python if it is installed', async () => { |
| 33 | + const pythonDir: string = path.join(toolDir, 'Python', '3.0.0', 'x64'); |
| 34 | + await io.mkdirP(pythonDir); |
| 35 | + fs.writeFileSync(`${pythonDir}.complete`, 'hello'); |
| 36 | + // This will throw if it doesn't find it in the cache (because no such version exists) |
| 37 | + await finder.findPythonVersion('3.x', 'x64'); |
| 38 | + }); |
| 39 | + |
| 40 | + it('Errors if Python is not installed', async () => { |
| 41 | + // This will throw if it doesn't find it in the cache (because no such version exists) |
| 42 | + let thrown = false; |
| 43 | + try { |
| 44 | + await finder.findPythonVersion('3.300000', 'x64'); |
| 45 | + } catch { |
| 46 | + thrown = true; |
| 47 | + } |
| 48 | + expect(thrown).toBeTruthy(); |
| 49 | + }); |
| 50 | + |
| 51 | + it('Finds PyPy if it is installed', async () => { |
| 52 | + const pythonDir: string = path.join(toolDir, 'PyPy', '2.0.0', 'x64'); |
| 53 | + await io.mkdirP(pythonDir); |
| 54 | + fs.writeFileSync(`${pythonDir}.complete`, 'hello'); |
| 55 | + // This will throw if it doesn't find it in the cache (because no such version exists) |
| 56 | + await finder.findPythonVersion('pypy2', 'x64'); |
| 57 | + }); |
| 58 | +}); |
0 commit comments