Skip to content

Commit

Permalink
Singleton dialog merge was not working properly (microsoft#3304)
Browse files Browse the repository at this point in the history
so it was fixed to work and tests were added.
Also made it so merge messages better reflect what is going on.
Fixed some other minor issues as well.
  • Loading branch information
chrimc62 authored Jun 4, 2021
1 parent 0843d8c commit bc4d5d1
Show file tree
Hide file tree
Showing 10 changed files with 1,968 additions and 242 deletions.
2 changes: 1 addition & 1 deletion experimental/generation/generator/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"999999",
"--colors",
"-g",
".*merge: self.*"
".*"
],
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function stringify(val: any, replacer?: any): string {
return val
}

function computeJSONHash(json: any): string {
export function computeJSONHash(json: any): string {
return computeHash(stringify(json))
}

Expand Down
311 changes: 165 additions & 146 deletions experimental/generation/generator/packages/library/src/mergeAssets.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$askIf": {
"type": "string",
"$role": "expression",
"title": "AskIF",
"title": "AskIf",
"description": "Boolean expression to add for when a property should be asked for. For example, the property IsPregnant could have a condition like $gender = 'female'."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "number",
"$generator": {
"title": "Number",
"description": "Map a LUIS number entity like '1' or '3.2' into a number and units.",
"description": "Map a LUIS number entity like '1' or '3.2' into a number.",
"allOf": [
{
"$ref": "minmax.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ function removeHash(val: string): string {
}

// NOTE: If you update dialog:merge functionality you need to execute the makeOracles.cmd to update them
async function compareToOracle(name: string, oraclePath?: string): Promise<void> {
let generatedPath = ppath.join(tempDir, name)
const generateds = removeHash(await fs.readFile(generatedPath, 'utf8'))
export async function compareToOracle(path: string, oraclePath?: string): Promise<void> {
const name = ppath.basename(path)
const generateds = removeHash(await fs.readFile(path, 'utf8'))
oraclePath = oraclePath ? ppath.join(tempDir, oraclePath) : ppath.join('test/oracles', name)
const oracle = await fs.readFile(oraclePath, 'utf8')
const oracles = removeHash(gen.normalizeEOL(oracle))
Expand Down Expand Up @@ -71,7 +71,7 @@ async function compareToOracle(name: string, oraclePath?: string): Promise<void>
console.log(`Oracle : ${oracles.substring(start, end)}`)
console.log(`Generated: ${generateds.substring(start, end)}`)
assert(false,
`${ppath.resolve(generatedPath)} does not match oracle ${ppath.resolve(oraclePath)}`)
`${ppath.resolve(path)} does not match oracle ${ppath.resolve(oraclePath)}`)
}
}

Expand Down Expand Up @@ -160,7 +160,7 @@ describe('dialog:generate library', async () => {
try {
console.log('\n\nTranscript test')
assert.ok(await generateTest('test/transcripts/sandwich.transcript', 'sandwich', output, false), 'Could not generate test script')
await compareToOracle('sandwich.test.dialog')
await compareToOracle(ppath.join(tempDir, 'sandwich.test.dialog'))
} catch (e) {
assert.fail(e.message)
}
Expand All @@ -170,7 +170,7 @@ describe('dialog:generate library', async () => {
try {
console.log('\n\nTranscript test')
assert.ok(await generateTest('test/transcripts/addItemWithButton.transcript', 'msmeeting-actions', output, false), 'Could not generate test script')
await compareToOracle('addItemWithButton.test.dialog')
await compareToOracle(ppath.join(tempDir, 'addItemWithButton.test.dialog'))
} catch (e) {
assert.fail(e.message)
}
Expand Down Expand Up @@ -480,7 +480,7 @@ describe('dialog:generate library', async () => {
})), 'Should not have failed generation')
assert.strictEqual(errors, 0, 'Wrong number of errors')
assert.strictEqual(warnings, 3, 'Wrong number of warnings')
await compareToOracle('unittest_transforms.dialog')
await compareToOracle(ppath.join(tempDir, 'unittest_transforms.dialog'))
} catch (e) {
assert.fail(e.message)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@ set ds=..\..\cli\bin\run

call node %ds% dialog:generate:test transcripts/sandwich.transcript sandwich -o oracles
call node %ds% dialog:generate:test transcripts/addItemWithButton.transcript msmeeting-actions -o oracles

call node %ds% dialog:generate forms/unittest_transforms.form -o %temp%\unittest_transforms -t templates -t templates/override -t template:standard -T addOne
copy %temp%\unittest_transforms\unittest_transforms.dialog oracles
copy %temp%\unittest_transforms\unittest_transforms.dialog oracles

call node %ds% dialog:generate merge_data/sandwichMerge.form -p sandwichMerge -o %temp%\merge
call node %ds% dialog:generate merge_data/sandwichMerge-modified.form -p sandwichMerge -o %temp%\merge --merge
copy %temp%\merge\sandwichMerge.dialog oracles
Loading

0 comments on commit bc4d5d1

Please sign in to comment.