This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add configuration to enable/disable RCC live execution
- Loading branch information
1 parent
003e28d
commit 99f3f79
Showing
6 changed files
with
177 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import * as assert from 'node:assert' | ||
import * as fs from 'node:fs' | ||
import * as path from 'node:path' | ||
import { | ||
E2E_TIMEOUT, | ||
setupE2EEnvironment, | ||
sleep, | ||
TEST_ASSETS_PATH, | ||
waitFor, | ||
} from '../test-utils' | ||
|
||
suite('rcc-live-execution/e2e', () => { | ||
const sampleQrcFilenameNoExt = 'sample' | ||
|
||
let originalFullText: string | ||
|
||
suiteSetup(async function () { | ||
this.timeout(E2E_TIMEOUT) | ||
await setupE2EEnvironment() | ||
}) | ||
|
||
setup(async function () { | ||
this.timeout(E2E_TIMEOUT) | ||
await removeGeneratedFile(sampleQrcFilenameNoExt) | ||
}) | ||
|
||
teardown(async function () { | ||
this.timeout(E2E_TIMEOUT) | ||
await removeGeneratedFile(sampleQrcFilenameNoExt) | ||
}) | ||
|
||
suite('when qrc file changed', () => { | ||
const qrcFilePath = path.resolve( | ||
TEST_ASSETS_PATH, | ||
'qrc', | ||
`${sampleQrcFilenameNoExt}.qrc`, | ||
) | ||
|
||
setup(async function () { | ||
this.timeout(E2E_TIMEOUT) | ||
originalFullText = fs.readFileSync(qrcFilePath, { encoding: 'utf-8' }) | ||
}) | ||
|
||
teardown(function () { | ||
this.timeout(E2E_TIMEOUT) | ||
fs.writeFileSync(qrcFilePath, originalFullText, { encoding: 'utf-8' }) | ||
}) | ||
|
||
test('should recompile', async () => { | ||
fs.writeFileSync( | ||
qrcFilePath, | ||
originalFullText.replace(/<file>rc0.txt<\/file>/gi, ''), | ||
) | ||
|
||
await waitFor(() => | ||
assert.ok( | ||
fs.existsSync( | ||
path.resolve( | ||
TEST_ASSETS_PATH, | ||
'qrc', | ||
`rc_${sampleQrcFilenameNoExt}.py`, | ||
), | ||
), | ||
), | ||
) | ||
}).timeout(E2E_TIMEOUT) | ||
}) | ||
|
||
suite('when a resource file changed', () => { | ||
const sampleResourceFilename = 'rc1.txt' | ||
|
||
const resourceFilePath = path.resolve( | ||
TEST_ASSETS_PATH, | ||
'qrc', | ||
sampleResourceFilename, | ||
) | ||
|
||
setup(async function () { | ||
this.timeout(E2E_TIMEOUT) | ||
originalFullText = fs.readFileSync(resourceFilePath, { | ||
encoding: 'utf-8', | ||
}) | ||
}) | ||
|
||
teardown(function () { | ||
this.timeout(E2E_TIMEOUT) | ||
fs.writeFileSync(resourceFilePath, originalFullText, { | ||
encoding: 'utf-8', | ||
}) | ||
}) | ||
|
||
test('should recompile', async () => { | ||
fs.writeFileSync( | ||
resourceFilePath, | ||
originalFullText.replace(/hello/gi, 'world'), | ||
) | ||
|
||
await waitFor(() => | ||
assert.ok( | ||
fs.existsSync( | ||
path.resolve( | ||
TEST_ASSETS_PATH, | ||
'qrc', | ||
`rc_${sampleQrcFilenameNoExt}.py`, | ||
), | ||
), | ||
), | ||
) | ||
}) | ||
}) | ||
}).timeout(E2E_TIMEOUT) | ||
|
||
async function removeGeneratedFile(sampleFilenameNoExt: string) { | ||
return waitFor(async () => { | ||
await sleep() // Wait for the file to be created asynchronously by the extension | ||
fs.rmSync( | ||
path.resolve(TEST_ASSETS_PATH, 'qrc', `rc_${sampleFilenameNoExt}.py`), | ||
{ force: true, recursive: true }, | ||
) | ||
assert.ok( | ||
!fs.existsSync( | ||
path.resolve(TEST_ASSETS_PATH, 'qrc', `rc_${sampleFilenameNoExt}.py`), | ||
), | ||
) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters