-
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.
Improve and Document Test Structure (#507)
* refactor: clean up setting minimum log level in`main.spec.ts` * refactor: starting to clean up `util` tests * refactor: restructure `util` folder * refactor: enforce non-recursive nature of `requireAllTestsInFolder` * refactor: statistics tests now use the new `-tests` suffix scheme * refactor: `slicing` tests folder * refactor: `flowr` test folder * refactor: `dataflow` folder + sanity check for requiring all testfiles * refactor, test-fix: deal with new sanity check findings * refactor: `benchmark-slicer` test folder * lint-fix: deal with unused import lintr issues * doc: document tests and how their basic structure works
- Loading branch information
1 parent
aefbf04
commit 596b70f
Showing
70 changed files
with
457 additions
and
259 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
File renamed without changes.
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,18 @@ | ||
import fs from 'node:fs' | ||
import path from 'path' | ||
|
||
/** | ||
* Require all files in a folder that end with a suffix, will never recurse into subfolders | ||
* @param folder - the folder to require all files from | ||
* @param suffix - the suffix which the files of interest must have | ||
*/ | ||
export function requireAllTestsInFolder(folder: string, suffix = '-tests.ts'): void { | ||
for(const fileBuff of fs.readdirSync(folder, { recursive: false })) { | ||
const file = fileBuff.toString() | ||
if(file.endsWith(suffix)) { | ||
require(path.join(folder,file)) | ||
} else if(!file.endsWith('.spec.ts')) { | ||
throw new Error(`Unexpected file ${file} in ${folder}, neither matches the import suffix '${suffix}', nor the test suffix '.spec.ts'. This is a sanity check so no files are lost. Please restructure your folders if this is intended.`) | ||
} | ||
} | ||
} |
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,7 @@ | ||
import { NodeId } from '../../../src/r-bridge' | ||
import { IdentifierDefinition } from '../../../src/dataflow' | ||
import { LocalScope } from '../../../src/dataflow/environments/scopes' | ||
|
||
export function variable(name: string, definedAt: NodeId): IdentifierDefinition { | ||
return { name, kind: 'variable', scope: LocalScope, used: 'always', nodeId: '_0', definedAt } | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,16 +1,15 @@ | ||
import { requireAllTestsInFolder } from '../_helper/collect-tests' | ||
import path from 'path' | ||
|
||
describe('Dataflow', () => { | ||
require('./environments/environments') | ||
describe('Environments', () => | ||
requireAllTestsInFolder(path.join(__dirname, 'environments')) | ||
) | ||
|
||
describe('Graph', () => | ||
requireAllTestsInFolder(path.join(__dirname, 'graph')) | ||
) | ||
|
||
describe('Graph', () => { | ||
require('./graph/equal') | ||
}) | ||
|
||
describe('Extraction', () => { | ||
require('./elements/atomic') | ||
require('./elements/expression-lists') | ||
describe('Functions', () => { | ||
require('./elements/functions/function-definition') | ||
require('./elements/functions/function-call') | ||
}) | ||
}) | ||
require('./processing-of-elements/processing-of-elements') | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
...ionality/dataflow/environments/resolve.ts → ...ty/dataflow/environments/resolve-tests.ts
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
2 changes: 1 addition & 1 deletion
2
...tionality/dataflow/elements/lists/read.ts → ...f-elements/expression-lists/read-tests.ts
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
2 changes: 1 addition & 1 deletion
2
.../dataflow/elements/lists/uninteresting.ts → ...s/expression-lists/uninteresting-tests.ts
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
Oops, something went wrong.
596b70f
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
Total per-file
3804.5559240909092
ms (5170.359319412824
)3190.570812409091
ms (3747.790963743062
)1.19
Retrieve AST from R code
74.56589218181819
ms (146.8099284297801
)68.74045054545455
ms (132.55959690808635
)1.08
Normalize R AST
96.26604622727274
ms (155.31980088528658
)96.19992009090909
ms (156.15063334620123
)1.00
Produce dataflow information
67.10777218181818
ms (171.15683868512687
)66.09041786363636
ms (169.92667998599904
)1.02
Total per-slice
2.0174989008245396
ms (1.4109740347352995
)1.8411702253695927
ms (1.267065280512554
)1.10
Static slicing
1.42280678296949
ms (1.2731817766313591
)1.3684034386686694
ms (1.1799623517395228
)1.04
Reconstruct code
0.5771566862856531
ms (0.3880877652226172
)0.4553098527401606
ms (0.2299566392692304
)1.27
failed to reconstruct/re-parse
0
#0
#NaN
times hit threshold
0
#0
#NaN
reduction (characters)
0.7329390759026896
#0.7329390759026896
#1
reduction (normalized tokens)
0.720988345209971
#0.720988345209971
#1
This comment was automatically generated by workflow using github-action-benchmark.
596b70f
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
Total per-file
5263.65605614
ms (5814.868226927445
)5419.399718899999
ms (6111.491408384184
)0.97
Retrieve AST from R code
76.85367336
ms (67.01097143149245
)85.22318365999999
ms (79.41151212889127
)0.90
Normalize R AST
112.33219194
ms (69.67744944436191
)113.45254984
ms (69.72126242848063
)0.99
Produce dataflow information
162.1001241
ms (275.13110196515186
)164.38322226
ms (279.00889908327076
)0.99
Total per-slice
8.437385266529795
ms (14.054690917342569
)8.82827828085479
ms (14.575511768060265
)0.96
Static slicing
7.941200117842794
ms (13.94011342956602
)8.228727295296194
ms (14.45423896853327
)0.97
Reconstruct code
0.48773673947577545
ms (0.24228534846179905
)0.5898725311439794
ms (0.30780610835907124
)0.83
failed to reconstruct/re-parse
9
#9
#1
times hit threshold
967
#967
#1
reduction (characters)
0.898713819973478
#0.8987761232201357
#1.00
reduction (normalized tokens)
0.8579790415512589
#0.8582032343145828
#1.00
This comment was automatically generated by workflow using github-action-benchmark.