theprogrammablemind_4wp 7.5.0-beta.15 → 7.5.0-beta.16
Sign up to get free protection for your applications and to get access to all the features.
- package/client.js +27 -9
- package/lines.js +3 -0
- package/package.json +1 -1
- package/src/config.js +14 -1
package/client.js
CHANGED
@@ -678,9 +678,12 @@ const runTest = async (config, expected, { verbose, afterTest, testConfig, debug
|
|
678
678
|
defaultErrorHandler(error)
|
679
679
|
}
|
680
680
|
|
681
|
-
|
681
|
+
let objects = getObjects(config.config.objects)(config.uuid)
|
682
|
+
if (testConfig.testModuleName) {
|
683
|
+
objects = getObjects(config.config.objects)(config.getConfigs()[testConfig.testModuleName].uuid)
|
684
|
+
}
|
682
685
|
config.beforeQuery({ query: test, isModule: false, objects })
|
683
|
-
config.resetMotivations()
|
686
|
+
// config.resetMotivations()
|
684
687
|
try {
|
685
688
|
const result = await _process(config, test, { errorHandler, isTest: true })
|
686
689
|
result.query = test
|
@@ -791,7 +794,7 @@ const runTests = async (config, testFile, juicyBits) => {
|
|
791
794
|
const saveTest = async (testFile, config, test, expected, testConfig, saveDeveloper) => {
|
792
795
|
config.rebuild()
|
793
796
|
const objects = getObjects(config.config.objects)(config.uuid)
|
794
|
-
config.resetMotivations()
|
797
|
+
//config.resetMotivations()
|
795
798
|
config.beforeQuery({ query: test, isModule: false, objects })
|
796
799
|
console.log(test)
|
797
800
|
const result = await _process(config, test, { isTest: true })
|
@@ -1260,7 +1263,7 @@ const knowledgeModule = async ({
|
|
1260
1263
|
description: 'Entodicton knowledge module'
|
1261
1264
|
})
|
1262
1265
|
|
1263
|
-
parser.add_argument('-
|
1266
|
+
parser.add_argument('-tmn', '--testModuleName', { help: 'When running tests instead of using the current modules tests use the specified modules tests' })
|
1264
1267
|
parser.add_argument('-t', '--test', { action: 'store_true', help: 'Run the tests. Create tests by running with the --query + --save flag' })
|
1265
1268
|
parser.add_argument('-tv', '--testVerbose', { action: 'store_true', help: 'Run the tests in verbose mode. Create tests by running with the --query or --loop with the --save flag' })
|
1266
1269
|
parser.add_argument('-tva', '--testAllVerbose', { action: 'store_true', help: 'Run the tests in verbose mode. All the tests will be run instead of stopping at first failure. Create tests by running with the --query or --loop with the --save flag' })
|
@@ -1474,7 +1477,15 @@ const knowledgeModule = async ({
|
|
1474
1477
|
}
|
1475
1478
|
return
|
1476
1479
|
}
|
1477
|
-
|
1480
|
+
let useTestConfig = testConfig
|
1481
|
+
if (args.testModuleName) {
|
1482
|
+
useTestConfig = config.getConfigs()[args.testModuleName].getTestConfig()
|
1483
|
+
useTestConfig.testModuleName = args.testModuleName
|
1484
|
+
test = useTestConfig.name
|
1485
|
+
|
1486
|
+
}
|
1487
|
+
// runTests(config, args.testFileName ? `${args.testFileName}.test.json` : test, { debug: args.debug, testConfig: testConfig, verbose: args.testVerbose || args.testAllVerbose, stopAtFirstError: !args.testAllVerbose }).then((results) => {
|
1488
|
+
runTests(config, test, { debug: args.debug, testConfig: useTestConfig, verbose: args.testVerbose || args.testAllVerbose, stopAtFirstError: !args.testAllVerbose }).then((results) => {
|
1478
1489
|
if (results.length > 0 && args.vimdiff) {
|
1479
1490
|
for (const result of results) {
|
1480
1491
|
vimdiff(result.expected, result.actual)
|
@@ -1523,19 +1534,25 @@ const knowledgeModule = async ({
|
|
1523
1534
|
if (!headerShown) {
|
1524
1535
|
console.log(' Failure')
|
1525
1536
|
}
|
1526
|
-
|
1527
|
-
|
1537
|
+
const widths = [4, 18, 72]
|
1538
|
+
const lines = new Lines(widths)
|
1539
|
+
lines.setElement(1, 1, 'expected checked')
|
1540
|
+
lines.setElement(2, 2, JSON.stringify(result.expected.checked, null, 2))
|
1541
|
+
lines.log()
|
1542
|
+
lines.setElement(1, 1, 'actual checked')
|
1543
|
+
lines.setElement(2, 2, JSON.stringify(result.actual.checked, null, 2))
|
1544
|
+
lines.log()
|
1528
1545
|
newError = true
|
1529
1546
|
headerShown = true
|
1530
1547
|
}
|
1531
1548
|
}
|
1532
1549
|
}
|
1533
1550
|
if (!headerShown) {
|
1534
|
-
if (!(
|
1551
|
+
if (!(useTestConfig.check && useTestConfig.check.length > 0)) {
|
1535
1552
|
console.log('There are failures due to things other than paraphrases, responses and checked properties being different. They are not shown because you ran -tv or -tva which only shows difference in paraphrase and results. Usually what I do is -s and do a diff to make sure there are no other problems. If the paraphrases or results were different they would have shown here.')
|
1536
1553
|
}
|
1537
1554
|
}
|
1538
|
-
if (!(
|
1555
|
+
if (!(useTestConfig.check && useTestConfig.check.length > 0)) {
|
1539
1556
|
console.log('use -v arg to write files expected.json and actual.json in the current directory for detailed comparison. Or do -s and then git diff the changes.')
|
1540
1557
|
// console.log(JSON.stringify(contexts))
|
1541
1558
|
console.log('**************************** ERRORS ************************')
|
@@ -1597,6 +1614,7 @@ const knowledgeModule = async ({
|
|
1597
1614
|
}
|
1598
1615
|
} else {
|
1599
1616
|
config.addAssociationsFromTests(config.tests);
|
1617
|
+
config.setTestConfig(testConfig)
|
1600
1618
|
//for (let query in config.tests) {
|
1601
1619
|
// config.addAssociations(config.tests[query].associations || []);
|
1602
1620
|
//}
|
package/lines.js
CHANGED
@@ -12,6 +12,9 @@ class Lines {
|
|
12
12
|
// will wrap to next line within the column
|
13
13
|
setElement (row, column, value) {
|
14
14
|
const values = value.toString().split('\n')
|
15
|
+
if (column >= this.widths.length) {
|
16
|
+
throw "Column out of range."
|
17
|
+
}
|
15
18
|
const width = this.widths[column]
|
16
19
|
let index = 0
|
17
20
|
for (value of values) {
|
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -330,6 +330,17 @@ class Config {
|
|
330
330
|
return `${maybeName}${counter}`
|
331
331
|
}
|
332
332
|
|
333
|
+
setTestConfig(testConfig) {
|
334
|
+
if (this.name == 'ui') {
|
335
|
+
console.log('ui setting testConfig')
|
336
|
+
}
|
337
|
+
this.testConfig = testConfig
|
338
|
+
}
|
339
|
+
|
340
|
+
getTestConfig() {
|
341
|
+
return this.testConfig
|
342
|
+
}
|
343
|
+
|
333
344
|
defaultConfig () {
|
334
345
|
this.config = {
|
335
346
|
operators: [], // TODO
|
@@ -1379,12 +1390,13 @@ class Config {
|
|
1379
1390
|
cp.name = this.name
|
1380
1391
|
cp.description = this.description
|
1381
1392
|
cp.tests = this.tests
|
1382
|
-
cp.motivations = this.motivations
|
1393
|
+
cp.motivations = [...this.motivations]
|
1383
1394
|
cp.isModule = this.isModule
|
1384
1395
|
cp.loadedForTesting = this.loadedForTesting
|
1385
1396
|
cp.initInstances = this.initInstances.slice()
|
1386
1397
|
cp.instances = this.instances.slice()
|
1387
1398
|
cp.configCounter = this.configCounter
|
1399
|
+
cp.testConfig = this.testConfig
|
1388
1400
|
|
1389
1401
|
cp.initConfig = _.cloneDeep(this.initConfig)
|
1390
1402
|
cp.defaultConfig()
|
@@ -1747,6 +1759,7 @@ class Config {
|
|
1747
1759
|
}
|
1748
1760
|
this.config.objects.namespaced = {}
|
1749
1761
|
this.resetWasInitialized()
|
1762
|
+
this.resetMotivations()
|
1750
1763
|
|
1751
1764
|
// reorder configs base on load ordering
|
1752
1765
|
{
|