From 6832e1c10124f193f35fcd2a04384f6fb58121fe Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 8 Oct 2021 12:30:10 +0530 Subject: [PATCH 1/5] enable back remix-tests CLI unit tests --- .../assert_ok_without_console_test.sol | 12 ++++++++++++ ...i.spec_disabled.ts => testRunner.cli.spec.ts} | 16 ++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 libs/remix-tests/tests/examples_0/assert_ok_without_console_test.sol rename libs/remix-tests/tests/{testRunner.cli.spec_disabled.ts => testRunner.cli.spec.ts} (93%) diff --git a/libs/remix-tests/tests/examples_0/assert_ok_without_console_test.sol b/libs/remix-tests/tests/examples_0/assert_ok_without_console_test.sol new file mode 100644 index 0000000000..030552b16a --- /dev/null +++ b/libs/remix-tests/tests/examples_0/assert_ok_without_console_test.sol @@ -0,0 +1,12 @@ +import "remix_tests.sol"; // this import is automatically injected by Remix. + +contract AssertOkTest { + + function okPassTest() public { + Assert.ok(true, "okPassTest passes"); + } + + function okFailTest() public { + Assert.ok(false, "okFailTest fails"); + } +} \ No newline at end of file diff --git a/libs/remix-tests/tests/testRunner.cli.spec_disabled.ts b/libs/remix-tests/tests/testRunner.cli.spec.ts similarity index 93% rename from libs/remix-tests/tests/testRunner.cli.spec_disabled.ts rename to libs/remix-tests/tests/testRunner.cli.spec.ts index 91174355af..ba0d7d2ff6 100644 --- a/libs/remix-tests/tests/testRunner.cli.spec_disabled.ts +++ b/libs/remix-tests/tests/testRunner.cli.spec.ts @@ -40,7 +40,7 @@ Commands: }) test('remix-tests running a test file', () => { - const res = spawnSync(executablePath, [resolve(__dirname + '/examples_0/assert_ok_test.sol')]) + const res = spawnSync(executablePath, [resolve(__dirname + '/examples_0/assert_ok_without_console_test.sol')]) // match initial lines expect(res.stdout.toString().trim()).toMatch(/:: Running remix-tests - Unit testing for solidity ::/) expect(res.stdout.toString().trim()).toMatch(/creation of library remix_tests.sol:Assert pending.../) @@ -55,7 +55,7 @@ Commands: }) test('remix-tests running a test file with custom compiler version', () => { - const res = spawnSync(executablePath, ['--compiler', '0.7.4', resolve(__dirname + '/examples_0/assert_ok_test.sol')]) + const res = spawnSync(executablePath, ['--compiler', '0.7.4', resolve(__dirname + '/examples_0/assert_ok_without_console_test.sol')]) // match initial lines expect(res.stdout.toString().trim().includes('Compiler version set to 0.7.4. Latest version is')).toBeTruthy() expect(res.stdout.toString().trim().includes('Loading remote solc version v0.7.4+commit.3f05b770 ...')).toBeTruthy() @@ -69,13 +69,13 @@ Commands: }) test('remix-tests running a test file with unavailable custom compiler version (should fail)', () => { - const res = spawnSync(executablePath, ['--compiler', '1.10.4', resolve(__dirname + '/examples_0/assert_ok_test.sol')]) + const res = spawnSync(executablePath, ['--compiler', '1.10.4', resolve(__dirname + '/examples_0/assert_ok_without_console_test.sol')]) // match initial lines expect(res.stdout.toString().trim().includes('No compiler found in releases with version 1.10.4')).toBeTruthy() }) test('remix-tests running a test file with custom EVM', () => { - const res = spawnSync(executablePath, ['--evm', 'petersburg', resolve(__dirname + '/examples_0/assert_ok_test.sol')]) + const res = spawnSync(executablePath, ['--evm', 'petersburg', resolve(__dirname + '/examples_0/assert_ok_without_console_test.sol')]) // match initial lines expect(res.stdout.toString().trim().includes('EVM set to petersburg')).toBeTruthy() expect(res.stdout.toString().trim()).toMatch(/:: Running remix-tests - Unit testing for solidity ::/) @@ -88,7 +88,7 @@ Commands: }) test('remix-tests running a test file by enabling optimization', () => { - const res = spawnSync(executablePath, ['--optimize', 'true', resolve(__dirname + '/examples_0/assert_ok_test.sol')]) + const res = spawnSync(executablePath, ['--optimize', 'true', resolve(__dirname + '/examples_0/assert_ok_without_console_test.sol')]) // match initial lines expect(res.stdout.toString().trim().includes('Optimization is enabled')).toBeTruthy() expect(res.stdout.toString().trim()).toMatch(/:: Running remix-tests - Unit testing for solidity ::/) @@ -101,7 +101,7 @@ Commands: }) test('remix-tests running a test file by enabling optimization and setting runs', () => { - const res = spawnSync(executablePath, ['--optimize', 'true', '--runs', '300', resolve(__dirname + '/examples_0/assert_ok_test.sol')]) + const res = spawnSync(executablePath, ['--optimize', 'true', '--runs', '300', resolve(__dirname + '/examples_0/assert_ok_without_console_test.sol')]) // match initial lines expect(res.stdout.toString().trim().includes('Optimization is enabled')).toBeTruthy() expect(res.stdout.toString().trim().includes('Runs set to 300')).toBeTruthy() @@ -115,13 +115,13 @@ Commands: }) test('remix-tests running a test file without enabling optimization and setting runs (should fail)', () => { - const res = spawnSync(executablePath, ['--runs', '300', resolve(__dirname + '/examples_0/assert_ok_test.sol')]) + const res = spawnSync(executablePath, ['--runs', '300', resolve(__dirname + '/examples_0/assert_ok_without_console_test.sol')]) // match initial lines expect(res.stdout.toString().trim().includes('Optimization should be enabled for runs')).toBeTruthy() }) test('remix-tests running a test file with all options', () => { - const res = spawnSync(executablePath, ['--compiler', '0.7.5', '--evm', 'istanbul', '--optimize', 'true', '--runs', '250', resolve(__dirname + '/examples_0/assert_ok_test.sol')]) + const res = spawnSync(executablePath, ['--compiler', '0.7.5', '--evm', 'istanbul', '--optimize', 'true', '--runs', '250', resolve(__dirname + '/examples_0/assert_ok_without_console_test.sol')]) // match initial lines expect(res.stdout.toString().trim().includes('Compiler version set to 0.7.5. Latest version is')).toBeTruthy() expect(res.stdout.toString().trim().includes('Loading remote solc version v0.7.5+commit.eb77ed08 ...')).toBeTruthy() From f56472b74896bc00cdd33ee2cefcfe5b28439e51 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 8 Oct 2021 13:24:02 +0530 Subject: [PATCH 2/5] clean cache before npm install --- libs/remix-tests/tests/testRunner.cli.spec.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/remix-tests/tests/testRunner.cli.spec.ts b/libs/remix-tests/tests/testRunner.cli.spec.ts index ba0d7d2ff6..255ace4898 100644 --- a/libs/remix-tests/tests/testRunner.cli.spec.ts +++ b/libs/remix-tests/tests/testRunner.cli.spec.ts @@ -10,7 +10,10 @@ describe('testRunner: remix-tests CLI', () => { if(result) { const dirContent = result.stdout.toString() // Install dependencies if 'node_modules' is not already present - if(!dirContent.includes('node_modules')) execSync('npm install', { cwd: resolve(__dirname + '/../../../dist/libs/remix-tests') }) + if(!dirContent.includes('node_modules')) { + execSync('npm cache clean --force', { cwd: resolve(__dirname + '/../../../dist/libs/remix-tests') }) + execSync('npm install', { cwd: resolve(__dirname + '/../../../dist/libs/remix-tests') }) + } } From 3995f3542f4100084b084751886e5db685bbdbfe Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 8 Oct 2021 14:00:01 +0530 Subject: [PATCH 3/5] single command --- libs/remix-tests/tests/testRunner.cli.spec.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/remix-tests/tests/testRunner.cli.spec.ts b/libs/remix-tests/tests/testRunner.cli.spec.ts index 255ace4898..07301c0e16 100644 --- a/libs/remix-tests/tests/testRunner.cli.spec.ts +++ b/libs/remix-tests/tests/testRunner.cli.spec.ts @@ -11,8 +11,7 @@ describe('testRunner: remix-tests CLI', () => { const dirContent = result.stdout.toString() // Install dependencies if 'node_modules' is not already present if(!dirContent.includes('node_modules')) { - execSync('npm cache clean --force', { cwd: resolve(__dirname + '/../../../dist/libs/remix-tests') }) - execSync('npm install', { cwd: resolve(__dirname + '/../../../dist/libs/remix-tests') }) + execSync('npm cache clean --force && npm install', { cwd: resolve(__dirname + '/../../../dist/libs/remix-tests') }) } } From e24e8b4ac648e59c46352ae28f3d46a474130d65 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 8 Oct 2021 14:16:33 +0530 Subject: [PATCH 4/5] install remix-tests CLI deps from CI --- .circleci/config.yml | 3 ++- libs/remix-tests/tests/testRunner.cli.spec.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4d422599c2..6e613bb6c4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,7 +51,8 @@ jobs: - checkout - run: npm install - run: npm run build:libs - - run: npm run test:libs + - run: cd dist/libs/remix-tests && npm install + - run: cd ../../.. && npm run test:libs remix-ide-chrome-1: docker: diff --git a/libs/remix-tests/tests/testRunner.cli.spec.ts b/libs/remix-tests/tests/testRunner.cli.spec.ts index 07301c0e16..496f6f4936 100644 --- a/libs/remix-tests/tests/testRunner.cli.spec.ts +++ b/libs/remix-tests/tests/testRunner.cli.spec.ts @@ -11,7 +11,7 @@ describe('testRunner: remix-tests CLI', () => { const dirContent = result.stdout.toString() // Install dependencies if 'node_modules' is not already present if(!dirContent.includes('node_modules')) { - execSync('npm cache clean --force && npm install', { cwd: resolve(__dirname + '/../../../dist/libs/remix-tests') }) + execSync('npm install', { cwd: resolve(__dirname + '/../../../dist/libs/remix-tests') }) } } From 3a256ee2d25513f3c6296c7d8510d214695ace44 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Fri, 8 Oct 2021 14:32:27 +0530 Subject: [PATCH 5/5] dir fix --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6e613bb6c4..7fcd0cd3d1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,7 +52,7 @@ jobs: - run: npm install - run: npm run build:libs - run: cd dist/libs/remix-tests && npm install - - run: cd ../../.. && npm run test:libs + - run: npm run test:libs remix-ide-chrome-1: docker: