-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test(systest): implement structure for basic system tests (#1164) * lint-fix(systest): fix any value (#1164) * test(systests): run test for flowr server (#1164) * lint(systests): lin fix (#1164) * refactor(systests): use childprocess instead of zx (#1164) * test-fix(systests): newline at end of file (#1164) * ci(systets): add systests to ci (#1164) * ci-fix(systest): extend test timeout (#1164) * lint(systest): format config (#1164) * refactor(test): defer math ast parsing in normalized ast fold * refactor(system-tests): concat buffers in checking server output * refactor(system-tests): sequentialize * wip(debug): print stdout for server test * wip(server-tests): only run server test for output * refactor(server-test): kill the server thread with a sigkill --------- Co-authored-by: Florian Sihler <[email protected]>
- Loading branch information
1 parent
d9a91cb
commit 0a57e68
Showing
8 changed files
with
146 additions
and
9 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
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,16 @@ | ||
import { assert, describe, test } from 'vitest'; | ||
import { run } from './utility/utility'; | ||
|
||
|
||
describe('commands', () => { | ||
test('flowr as server', async() => { | ||
const expected = 'Server listening on port'; | ||
const output = await run('npm run flowr -- --server', expected); | ||
assert.include(output, expected); | ||
}); | ||
|
||
test('slicer', async() => { | ||
const output = await run('npm run slicer -- -c "3@a" -r "a <- 3\\nb <- 4\\nprint(a)"'); | ||
assert.include(output, 'a <- 3\na'); | ||
}); | ||
}); |
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,24 @@ | ||
import { assert, describe, test } from 'vitest'; | ||
import { flowrRepl } from './utility/utility'; | ||
|
||
describe('repl', () => { | ||
test(':df', async() => { | ||
const output = await flowrRepl([':df test', ':quit']); | ||
assert.include(output, 'flowchart'); | ||
}); | ||
|
||
test(':df x <- 3', async() => { | ||
const output = await flowrRepl([':df x <- 3 ', ':quit']); | ||
assert.include(output, 'flowchart'); | ||
}); | ||
|
||
test(':df "x <- 3\nprint(x)"', async() => { | ||
const output = await flowrRepl([':df "x <- 3\\nprint(x)"', ':quit']); | ||
assert.include(output, 'flowchart'); | ||
}); | ||
|
||
test(':slicer', async() => { | ||
const output = await flowrRepl([':slicer -c "3@a" -r "a <- 3\\nb <- 4\\nprint(a)"', ':quit']); | ||
assert.include(output, 'a <- 3\na'); | ||
}); | ||
}); |
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,70 @@ | ||
import { exec } from 'child_process'; | ||
|
||
/** | ||
* Runs the flowr repl and feeds input to the repl | ||
* @param input - input to feed | ||
* @returns Repl Output | ||
*/ | ||
|
||
export async function flowrRepl(input: string[]): Promise<string> { | ||
const process = new Promise<string>((resolve, reject) => { | ||
const child = exec('npm run flowr', { timeout: 60 * 1000 }, (error, stdout, _) => { | ||
if(error) { | ||
reject(new Error(`${error.name}: ${error.message}\n${stdout}`)); | ||
} | ||
|
||
resolve(stdout); | ||
}); | ||
|
||
// Send new data when flowr sends us the 'R>' prompt to avoid | ||
// sending data too fast | ||
let i = 0; | ||
child.stdout?.on('data', (d) => { | ||
const data = d as Buffer; | ||
|
||
if(data.toString().includes('R>')) { | ||
if(i < input.length) { | ||
child.stdin?.write(`${input[i++]}\n`); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
return await process; | ||
} | ||
|
||
/** | ||
* Runs a command and terminates it automatically if it outputs a certain string | ||
* This is useful, so we don't have to set timeouts and hope the output will be produced in time. | ||
* | ||
* @param command - Command to run | ||
* @param terminateOn - (optional) string to kill the process on | ||
* @param timeout - (optional) timeout in milliseconds | ||
* @returns output of command | ||
*/ | ||
export async function run(command: string, terminateOn?: string, timeout = 60 * 1000): Promise<string> { | ||
const process = new Promise<string>((resolve, reject) => { | ||
const child = exec(command, { timeout }, (error, stdout, _) => { | ||
if(error) { | ||
reject(new Error(`${error.name}: ${error.message}\n${stdout}`)); | ||
} | ||
|
||
resolve(stdout); | ||
}); | ||
|
||
if(terminateOn) { | ||
let buffer = ''; | ||
child.stdout?.on('data', (d: Buffer) => { | ||
buffer += d.toString(); | ||
|
||
if(buffer.includes(terminateOn)) { | ||
child.kill('SIGKILL'); | ||
resolve(buffer); | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
return await process; | ||
} | ||
|
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,22 @@ | ||
import { defineConfig } from 'vitest/config'; | ||
|
||
export default defineConfig({ | ||
test: { | ||
testTimeout: 60 * 2000, | ||
sequence: { | ||
/* each test file that does not support parallel execution will be executed in sequence by stating this explicitly */ | ||
concurrent: true, | ||
setupFiles: 'parallel' | ||
}, | ||
reporters: process.env.GITHUB_ACTIONS ? ['basic', 'github-actions'] : ['dot'], | ||
isolate: false, | ||
pool: 'threads', | ||
deps: { | ||
optimizer: { | ||
ssr: { | ||
enabled: true | ||
} | ||
} | ||
} | ||
}, | ||
}); |
0a57e68
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"artificial" Benchmark Suite
Retrieve AST from R code
237.68530227272728
ms (98.66504059373398
)242.24415118181818
ms (104.26310147093089
)0.98
Normalize R AST
17.253183545454547
ms (30.54154579978084
)17.39715159090909
ms (31.09452227247912
)0.99
Produce dataflow information
63.3047335
ms (141.04477116891695
)60.33616290909091
ms (127.75990956872062
)1.05
Total per-file
828.229115
ms (1493.4796936583705
)833.5976102727273
ms (1502.9439844838432
)0.99
Static slicing
2.0327492495862898
ms (1.1986348658053698
)2.029558401836784
ms (1.2081663161038019
)1.00
Reconstruct code
0.23152153062389233
ms (0.1733261895732629
)0.23538053186242114
ms (0.17968366955783688
)0.98
Total per-slice
2.277994332634675
ms (1.2620198633086381
)2.278853130617715
ms (1.2795408953549086
)1.00
failed to reconstruct/re-parse
0
#0
#1
times hit threshold
0
#0
#1
reduction (characters)
0.7891949660994808
#0.7891949660994808
#1
reduction (normalized tokens)
0.7665650684287274
#0.7665650684287274
#1
memory (df-graph)
95.46617542613636
KiB (244.77619956879823
)95.46617542613636
KiB (244.77619956879823
)1
This comment was automatically generated by workflow using github-action-benchmark.
0a57e68
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"social-science" Benchmark Suite
Retrieve AST from R code
239.30871009999998
ms (43.27095668706109
)237.81388206
ms (43.26435892465071
)1.01
Normalize R AST
18.830496
ms (14.414331605000688
)18.584648960000003
ms (13.710753719051512
)1.01
Produce dataflow information
72.23594578
ms (66.90833939413633
)71.41246154000001
ms (65.6106108648961
)1.01
Total per-file
7634.2038686000005
ms (29047.300746916673
)7625.11364774
ms (29095.600821943466
)1.00
Static slicing
15.761166074529504
ms (44.4601733125231
)15.746698561898643
ms (44.50249372495068
)1.00
Reconstruct code
0.2493108138800615
ms (0.14770836830816605
)0.24344144772080362
ms (0.13994668646932817
)1.02
Total per-slice
16.018184013370995
ms (44.49503588444086
)15.997988500166153
ms (44.53599655284285
)1.00
failed to reconstruct/re-parse
0
#0
#1
times hit threshold
0
#0
#1
reduction (characters)
0.8762109251198998
#0.8762109251198998
#1
reduction (normalized tokens)
0.819994064355517
#0.819994064355517
#1
memory (df-graph)
99.526015625
KiB (113.60201607005874
)99.526015625
KiB (113.60201607005874
)1
This comment was automatically generated by workflow using github-action-benchmark.