Skip to content

Commit 7a5eec2

Browse files
committed
all remix-tests ut
1 parent 569de90 commit 7a5eec2

File tree

1 file changed

+101
-102
lines changed

1 file changed

+101
-102
lines changed

libs/remix-tests/tests/testRunner.cli.spec.ts

Lines changed: 101 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -58,108 +58,107 @@ Commands:
5858
expect(res.stdout.toString().trim()).to.equal(expectedHelp)
5959
})
6060

61-
// it('remix-tests running a test file', function() {
62-
// const res = spawnSync(executablePath, [resolve(__dirname + '/examples_0/assert_ok_test.sol')])
63-
// //console.log(res.stdout.toString())
64-
// // match initial lines
65-
// console.log(res.stdout.toString())
66-
// expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
67-
// expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
68-
// // match test result
69-
// expect(res.stdout.toString().trim()).to.match(/AssertOkTest/)
70-
// expect(res.stdout.toString().trim()).to.match(/AssertOkTest okPassTest/) // check if console.log is printed
71-
// expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
72-
// expect(res.stdout.toString().trim()).to.match(/AssertOkTest okFailTest/) // check if console.log is printed
73-
// expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
74-
// // match fail test details
75-
// expect(res.stdout.toString().trim()).to.match(/Expected value should be ok to: true/)
76-
// expect(res.stdout.toString().trim()).to.match(/Received: false/)
77-
// expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
78-
79-
// })
80-
81-
// it('remix-tests running a test file with custom compiler version', () => {
82-
// const res = spawnSync(executablePath, ['--compiler', '0.7.4', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
83-
// // match initial lines
84-
// expect(res.stdout.toString().trim()).to.contain('Compiler version set to 0.7.4. Latest version is')
85-
// expect(res.stdout.toString().trim()).to.contain('Loading remote solc version v0.7.4+commit.3f05b770 ...')
86-
// expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
87-
// expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
88-
// // match test result
89-
// expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
90-
// expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
91-
// // match fail test details
92-
// expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
93-
// })
94-
95-
// it('remix-tests running a test file with unavailable custom compiler version (should fail)', () => {
96-
// const res = spawnSync(executablePath, ['--compiler', '1.10.4', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
97-
// // match initial lines
98-
// expect(res.stdout.toString().trim()).to.contain('No compiler found in releases with version 1.10.4')
99-
// })
100-
101-
// it('remix-tests running a test file with custom EVM', () => {
102-
// const res = spawnSync(executablePath, ['--evm', 'petersburg', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
103-
// // match initial lines
104-
// expect(res.stdout.toString().trim()).to.contain('EVM set to petersburg')
105-
// expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
106-
// expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
107-
// // match test result
108-
// expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
109-
// expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
110-
// // match fail test details
111-
// expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
112-
// })
113-
114-
// it('remix-tests running a test file by enabling optimization', () => {
115-
// const res = spawnSync(executablePath, ['--optimize', 'true', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
116-
// // match initial lines
117-
// expect(res.stdout.toString().trim().includes('Optimization is enabled'))
118-
// expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
119-
// expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
120-
// // match test result
121-
// expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
122-
// expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
123-
// // match fail test details
124-
// expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
125-
// })
126-
127-
// it('remix-tests running a test file by enabling optimization and setting runs', () => {
128-
// const res = spawnSync(executablePath, ['--optimize', 'true', '--runs', '300', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
129-
// // match initial lines
130-
// expect(res.stdout.toString().trim()).to.contain('Optimization is enabled')
131-
// expect(res.stdout.toString().trim()).to.contain('Runs set to 300')
132-
// expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
133-
// expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
134-
// // match test result
135-
// expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
136-
// expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
137-
// // match fail test details
138-
// expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
139-
// })
140-
141-
// it('remix-tests running a test file without enabling optimization and setting runs (should fail)', () => {
142-
// const res = spawnSync(executablePath, ['--runs', '300', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
143-
// // match initial lines
144-
// expect(res.stdout.toString().trim()).to.contain('Optimization should be enabled for runs')
145-
// })
146-
147-
// it('remix-tests running a test file with all options', () => {
148-
// const res = spawnSync(executablePath, ['--compiler', '0.7.5', '--evm', 'istanbul', '--optimize', 'true', '--runs', '250', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
149-
// // match initial lines
150-
// expect(res.stdout.toString().trim()).to.contain('Compiler version set to 0.7.5. Latest version is')
151-
// expect(res.stdout.toString().trim()).to.contain('Loading remote solc version v0.7.5+commit.eb77ed08 ...')
152-
// expect(res.stdout.toString().trim()).to.contain('EVM set to istanbul')
153-
// expect(res.stdout.toString().trim()).to.contain('Optimization is enabled')
154-
// expect(res.stdout.toString().trim()).to.contain('Runs set to 250')
155-
// expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
156-
// expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
157-
// // match test result
158-
// expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
159-
// expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
160-
// // match fail test details
161-
// expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
162-
// })
61+
it('remix-tests running a test file', function() {
62+
const res = spawnSync(executablePath, [resolve(__dirname + '/examples_0/assert_ok_test.sol')])
63+
// match initial lines
64+
console.log(res.stdout.toString())
65+
expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
66+
expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
67+
// match test result
68+
expect(res.stdout.toString().trim()).to.match(/AssertOkTest/)
69+
expect(res.stdout.toString().trim()).to.match(/AssertOkTest okPassTest/) // check if console.log is printed
70+
expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
71+
expect(res.stdout.toString().trim()).to.match(/AssertOkTest okFailTest/) // check if console.log is printed
72+
expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
73+
// match fail test details
74+
expect(res.stdout.toString().trim()).to.match(/Expected value should be ok to: true/)
75+
expect(res.stdout.toString().trim()).to.match(/Received: false/)
76+
expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
77+
78+
})
79+
80+
it('remix-tests running a test file with custom compiler version', () => {
81+
const res = spawnSync(executablePath, ['--compiler', '0.7.4', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
82+
// match initial lines
83+
expect(res.stdout.toString().trim()).to.contain('Compiler version set to 0.7.4. Latest version is')
84+
expect(res.stdout.toString().trim()).to.contain('Loading remote solc version v0.7.4+commit.3f05b770 ...')
85+
expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
86+
expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
87+
// match test result
88+
expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
89+
expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
90+
// match fail test details
91+
expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
92+
})
93+
94+
it('remix-tests running a test file with unavailable custom compiler version (should fail)', () => {
95+
const res = spawnSync(executablePath, ['--compiler', '1.10.4', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
96+
// match initial lines
97+
expect(res.stdout.toString().trim()).to.contain('No compiler found in releases with version 1.10.4')
98+
})
99+
100+
it('remix-tests running a test file with custom EVM', () => {
101+
const res = spawnSync(executablePath, ['--evm', 'petersburg', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
102+
// match initial lines
103+
expect(res.stdout.toString().trim()).to.contain('EVM set to petersburg')
104+
expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
105+
expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
106+
// match test result
107+
expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
108+
expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
109+
// match fail test details
110+
expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
111+
})
112+
113+
it('remix-tests running a test file by enabling optimization', () => {
114+
const res = spawnSync(executablePath, ['--optimize', 'true', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
115+
// match initial lines
116+
expect(res.stdout.toString().trim().includes('Optimization is enabled'))
117+
expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
118+
expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
119+
// match test result
120+
expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
121+
expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
122+
// match fail test details
123+
expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
124+
})
125+
126+
it('remix-tests running a test file by enabling optimization and setting runs', () => {
127+
const res = spawnSync(executablePath, ['--optimize', 'true', '--runs', '300', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
128+
// match initial lines
129+
expect(res.stdout.toString().trim()).to.contain('Optimization is enabled')
130+
expect(res.stdout.toString().trim()).to.contain('Runs set to 300')
131+
expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
132+
expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
133+
// match test result
134+
expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
135+
expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
136+
// match fail test details
137+
expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
138+
})
139+
140+
it('remix-tests running a test file without enabling optimization and setting runs (should fail)', () => {
141+
const res = spawnSync(executablePath, ['--runs', '300', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
142+
// match initial lines
143+
expect(res.stdout.toString().trim()).to.contain('Optimization should be enabled for runs')
144+
})
145+
146+
it('remix-tests running a test file with all options', () => {
147+
const res = spawnSync(executablePath, ['--compiler', '0.7.5', '--evm', 'istanbul', '--optimize', 'true', '--runs', '250', resolve(__dirname + '/examples_0/assert_ok_test.sol')])
148+
// match initial lines
149+
expect(res.stdout.toString().trim()).to.contain('Compiler version set to 0.7.5. Latest version is')
150+
expect(res.stdout.toString().trim()).to.contain('Loading remote solc version v0.7.5+commit.eb77ed08 ...')
151+
expect(res.stdout.toString().trim()).to.contain('EVM set to istanbul')
152+
expect(res.stdout.toString().trim()).to.contain('Optimization is enabled')
153+
expect(res.stdout.toString().trim()).to.contain('Runs set to 250')
154+
expect(res.stdout.toString().trim()).to.match(/:: Running tests using remix-tests ::/)
155+
expect(res.stdout.toString().trim()).to.match(/creation of library remix_tests.sol:Assert pending.../)
156+
// match test result
157+
expect(res.stdout.toString().trim()).to.match(/Ok pass test/)
158+
expect(res.stdout.toString().trim()).to.match(/Ok fail test/)
159+
// match fail test details
160+
expect(res.stdout.toString().trim()).to.match(/Message: okFailTest fails/)
161+
})
163162

164163
})
165164
})

0 commit comments

Comments
 (0)