Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pack program info rather than reading JSON files dynamically in Go ru…
…nner (#129) * Pack program info * Add basic integration tests for dsq * Add test script * Debug * Create results directory if not exists * Generate packed info for diff * Drop all tests but dsq * Run tests on win/mac/linux * No integration test version * With powershell * Switch go * Correct image * Uninstall 1.15 * Drop cat * Add ids incase * Add more comments * Dont fail if dir exists * Dont fail if dir exists * Debugging * Run windows test in bash * Rearrange tests * Try with verbose * More debugging * Try another pipe detection * Verbose again * Add back old tests * Add support for pipe fallback * one more whitespace * one more whitespace * one more whitespace * Fix for fmt
- Loading branch information
Showing
8 changed files
with
140 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ TAGS | |
all.out | ||
runner/report | ||
runner/runner | ||
runner/runner.exe | ||
runner/runner.exe | ||
dsq |
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,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
types="csv parquet json" | ||
|
||
for t in $types; do | ||
echo "Testing $t (pipe)." | ||
sqlcount="$(cat ./testdata/userdata.$t | ./dsq $t 'SELECT COUNT(1) AS c FROM {}' | jq '.[0].c')" | ||
if [[ "$sqlcount" != "1000" ]]; then | ||
echo "Bad SQL count for $t (pipe). Expected 1000, got $sqlcount." | ||
exit 1 | ||
else | ||
echo "Pipe $t test successful." | ||
fi | ||
|
||
echo "Testing $t (file)." | ||
sqlcount="$(./dsq ./testdata/userdata.$t 'SELECT COUNT(1) AS c FROM {}' | jq '.[0].c')" | ||
if [[ "$sqlcount" != "1000" ]]; then | ||
echo "Bad SQL count for $t (file). Expected 1000, got $sqlcount." | ||
exit 1 | ||
else | ||
echo "File $t test successful." | ||
fi | ||
done |
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,11 @@ | ||
package runner | ||
|
||
// GENERATED BY ./runner/scripts/generate_program_type_info.sh. DO NOT MODIFY. | ||
|
||
var packedProgramTypeInfo = map[SupportedLanguages]string{ | ||
"javascript": `{"id":"javascript","preamble":"function DM_getPanelFile(i){ return '$$RESULTS_FILE$$'+$$JSON_ID_MAP$$[i];}\nfunction DM_getPanel(i) {\n const fs = require('fs');\n return JSON.parse(fs.readFileSync('$$RESULTS_FILE$$'+$$JSON_ID_MAP$$[i]));\n}\nfunction DM_setPanel(v) {\n const fs = require('fs');\n const fd = fs.openSync('$$PANEL_RESULTS_FILE$$', 'w');\n if (Array.isArray(v)) {\n fs.writeSync(fd, '[');\n for (let i = 0; i < v.length; i++) {\n const row = v[i];\n let rowJSON = JSON.stringify(row);\n if (i < v.length - 1) {\n rowJSON += ',';\n }\n fs.writeSync(fd, rowJSON);\n }\n fs.writeSync(fd, ']');\n } else {\n fs.writeSync(fd, JSON.stringify(v));\n }\n}","defaultPath":"node","name":"JavaScript"}`, | ||
"julia": `{"id":"julia","name":"Julia","defaultPath":"julia","preamble":"\ntry\n import JSON\ncatch e\n import Pkg\n Pkg.add(\"JSON\")\n import JSON\nend\nfunction DM_getPanel(i)\n panelId = JSON.parse(\"$$JSON_ID_MAP_QUOTE_ESCAPED$$\")[string(i)]\n JSON.parsefile(string(\"$$RESULTS_FILE$$\", panelId))\nend\nfunction DM_setPanel(v)\n open(\"$$PANEL_RESULTS_FILE$$\", \"w\") do f\n JSON.print(f, v)\n end\nend\nfunction DM_getPanelFile(i)\n string(\"$$RESULTS_FILE$$\", JSON.parse(\"$$JSON_ID_MAP_QUOTE_ESCAPED$$\")[string(i)])\nend"}`, | ||
"python": `{"id":"python","name":"Python","defaultPath":"python3","preamble":"def DM_getPanelFile(i):\n return r'$$RESULTS_FILE$$'+$$JSON_ID_MAP$$[str(i)]\ndef DM_getPanel(i):\n import json\n with open(r'$$RESULTS_FILE$$'+$$JSON_ID_MAP$$[str(i)]) as f:\n return json.load(f)\ndef DM_setPanel(v):\n import json\n with open(r'$$PANEL_RESULTS_FILE$$', 'w') as f:\n json.dump(v, f)"}`, | ||
"r": `{"id":"r","name":"R","defaultPath":"Rscript","preamble":"\ntryCatch(library(\"rjson\"), error=function(cond) {install.packages(\"rjson\", repos=\"https://cloud.r-project.org\")}, finally=library(\"rjson\"))\nDM_getPanel <- function(i) {\n panelId = fromJSON(\"$$JSON_ID_MAP_QUOTE_ESCAPED$$\")[[toString(i)]]\n fromJSON(file=paste(\"$$RESULTS_FILE$$\", panelId, sep=\"\"))\n}\nDM_setPanel <- function(v) {\n write(toJSON(v), \"$$PANEL_RESULTS_FILE$$\")\n}\nDM_getPanelFile <- function(i) {\n paste(\"$$RESULTS_FILE$$\", fromJSON(\"$$JSON_ID_MAP_QUOTE_ESCAPED$$\")[[toString(i)]], sep=\"\")\n}\n"}`, | ||
"ruby": `{"id":"ruby","name":"Ruby","defaultPath":"ruby","preamble":"\ndef DM_getPanel(i)\n require 'json'\n JSON.parse(File.read('$$RESULTS_FILE$$' + JSON.parse('$$JSON_ID_MAP$$')[i.to_s]))\nend\ndef DM_setPanel(v)\n require 'json'\n File.write('$$PANEL_RESULTS_FILE$$', v.to_json)\nend\ndef DM_getPanelFile(i)\n require 'json'\n '$$RESULTS_FILE$$' + JSON.parse('$$JSON_ID_MAP$$')[i.to_s]\nend\n"}`, | ||
} |
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 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
echo "package runner | ||
// GENERATED BY ./runner/scripts/generate_program_type_info.sh. DO NOT MODIFY. | ||
var packedProgramTypeInfo = map[SupportedLanguages]string{" > runner/program_info.go | ||
for file in $(ls ./shared/languages/*.json); do | ||
echo "$(cat $file | jq '.id'): \`$(cat $file | jq -c '.')\`," >> runner/program_info.go | ||
done | ||
|
||
echo "}" >> runner/program_info.go | ||
|
||
gofmt -w -s . |