Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,25 @@ jobs:
name: lcov
path: coverage-reports/lcov.info
retention-days: 1
test-q:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to GitLab
uses: docker/login-action@v3
with:
registry: registry.gitlab.com
username: ${{ secrets.GL_REG_USERNAME }}
password: ${{ secrets.GL_REG_TOKEN }}
- name: Run qCumber
run: ./qcumber.sh -src test/q/main.q -test test/q/tests
env:
KDB_K4LICENSE_B64: ${{ secrets.KDB_K4LICENSE_B64 }}


app-sec:
needs: test
needs: [test, test-q]
if: "! github.event.pull_request.head.repo.fork "
uses: ./.github/workflows/app-sec-template.yml
with:
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,24 @@ jobs:
name: lcov
path: coverage-reports/lcov.info
retention-days: 1
test-q:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to GitLab
uses: docker/login-action@v3
with:
registry: registry.gitlab.com
username: ${{ secrets.GL_REG_USERNAME }}
password: ${{ secrets.GL_REG_TOKEN }}
- name: Run qCumber
run: ./qcumber.sh -src test/q/main.q -test test/q/tests
env:
KDB_K4LICENSE_B64: ${{ secrets.KDB_K4LICENSE_B64 }}

app-sec:
needs: test
needs: [test, test-q]
if: "! github.event.pull_request.head.repo.fork "
uses: ./.github/workflows/app-sec-template.yml
with:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,8 @@
"preui-test-cmd": "tsc --outdir out-test --strict false",
"ui-test-cmd": "extest setup-and-run --code_version 1.101.0 --code_settings ./test/ui/fixtures/settings.json --extensions_dir ./.test-extensions --storage ./.test-folder -m ./test/ui/fixtures/mocha.json",
"preui-test": "rimraf out-test .test-extensions",
"ui-test": "npm run ui-test-cmd -- ./out-test/test/ui/**/*.test.js"
"ui-test": "npm run ui-test-cmd -- ./out-test/test/ui/**/*.test.js",
"q-test": "arch -x86_64 q $AXLIBRARIES_HOME/ws/qcumber.q_ -color -src ./test/q/main.q -test ./test/q"
},
"devDependencies": {
"@eslint/js": "9.39.1",
Expand Down
16 changes: 16 additions & 0 deletions qcumber.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Runs qcumber in a docker image
# usage:
# qcumber.sh -src test/main.q -test test

QBUILD_IMAGE="registry.gitlab.com/kxdev/cloud/packaging/qpacker/qpbuild:2.1.41"
CMD="/app/qbuild/scripts/qcumber -color -q $*"
SETUP="if [ -f /app/project/test/q/preTest.sh ]; then source /app/project/test/q/preTest.sh; fi"

docker run --rm \
-e KDB_K4LICENSE_B64 \
-v $(pwd):/app/project \
-w /app/project \
"$QBUILD_IMAGE" \
bash -c "$SETUP; $CMD"
2 changes: 2 additions & 0 deletions test/q/main.q
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@[system"l ",;"pykx.q";{::}]
if[getenv[`CI]~"true";system "cd /app/project"];
4 changes: 4 additions & 0 deletions test/q/preTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

pip install "pykx~=2.5"
python -c "import pykx;pykx.install_into_QHOME()"
167 changes: 167 additions & 0 deletions test/q/tests/evaluate.quke
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
feature EDI
before
.test.src: "\n" sv read0 `:resources/evaluate.q;
.test.evaluate: {[ctx; code; returnFormat]
0i (.test.src; ctx; code; returnFormat)
};
.test.dims : system "c";
.test.precision: system "P";
.test.attrLines: ("dict: `s#`a`b`c`d`e`f`g!enlist each 7?0";
"dict[`e] : dict[`e] , 1";
"attr dict");
after
delete dict from `.;

after each
system "c ", " " sv string .test.dims;
system "P ", string .test.precision;

// @TICKET KXI-9607
should ensure EDI performs display correctly for standard expressions
// @TICKET KXI-12260
expect simple expression of 3+3 to return 6:
.qu.compare[.test.evaluate["."; "3+3"; "serialized"]`result; 6]

// This test is skipped because coverage is not handling generic null correctly in QBUILD 1.0.17 and greater
// @TICKET KXI-12260
xexpect projection null to return as generic null
.qu.compare[.test.evaluate["."; "last value (;;)"; "serialized"]`result; (::)]

expect function definition to work:
.qu.compare[.test.evaluate["."; ".test.fn333: {: 333}"; "serialized"]`result; {: 333}]

expect function call to work and return 333:
.qu.compare[.test.evaluate["."; ".test.fn333 []"; "serialized"]`result; 333]

xexpect each right and each left of similar expressions to be equal:
.com_kx_edi.dropIrrelevantRecords[.com_kx_ediNoCoverage.evaluate["1 2 3 +\\: 10"; "."]] ~ .com_kx_edi.dropIrrelevantRecords .com_kx_ediNoCoverage.evaluate["10 +/: 1 2 3"; "."]

expect scan to work and return 11 13 16:
.qu.compare[.test.evaluate["."; "10 +\\ 1 2 3"; "serialized"]`result; 11 13 16]

expect over to work and return 16:
.qu.compare[.test.evaluate["."; "10 +/ 1 2 3"; "serialized"]`result; 16]

expect a list created by EDI to be equal to the list:
.qu.compare[.test.evaluate["."; "1 2 3 4 5 6 7 8"; "serialized"]`result; 1 2 3 4 5 6 7 8]

expect an expression that creates a list to return the correct list:
.qu.compare[.test.evaluate["."; "`char$97+til 26"; "serialized"]`result; "abcdefghijklmnopqrstuvwxyz"]

expect the concat of two lists to be the same:
.qu.compare[.test.evaluate["."; "(til 100),(til 100)"; "serialized"]`result; (til[100], til 100)]

// @TICKET KXI-9607
should ensure EDI performs display correctly for k expressions
expect simple k expressions to work, 3+3=6:
.qu.compare[.test.evaluate["."; "k) 3 + 3"; "serialized"]`result; 6]

expect more complicated k expressions to work such as over:
.qu.compare[.test.evaluate["."; "k) +/1 2 3 4"; "serialized"]`result; 10]

expect more complicated k expressions to work such as dyadic function over:
.qu.compare[.test.evaluate["."; "k) {x+2*y}/1 2 3 4"; "serialized"]`result; 19]

expect more complicated k expressions to work such as monadic each both:
.qu.compare[.test.evaluate["."; "k) (-':)1 2 3 4"; "serialized"]`result; 1 1 1 1]

expect more complicated k expressions to work such as monadic each both:
.qu.compare[.test.evaluate["."; "k) +\\1 2 3 4"; "serialized"]`result; 1 3 6 10]

expect a string to be a string in k:
.qu.compare[.test.evaluate["."; "k) \"hello\\\\there\""; "serialized"]`result; "hello\\there"]

// @TICKET KXI-9607
should ensure EDI performs display correctly for system expressions
expect it to return timing information:
// this fails intermittently on windows for some reason ...
10 > .test.evaluate["."; "\\t count \"doug\""; "serialized"]`result

expect expression in t to set zz correctly:
(.test.zz ~ 4) and (10 > .test.evaluate["."; "\\t .test.zz: count \"doug\""; "serialized"]`result)

expect simple expression in t to work correctly:
(.test.zz ~ 4) and (10 > .test.evaluate["."; "\\t .test.zz: 1 + 1 + 1 + 1"; "serialized"]`result)

expect ts to return time and space:
.qu.compare[count .test.evaluate["."; "\\ts til 10000"; "serialized"]`result; 2]

expect workspace information to return correctly (should usually work but may fail):
(last system "w") ~ last .test.evaluate["."; "\\w"; "serialized"]`result

expect ls os command to return data back as a general list equivalent to system call:
$["w" ~ first string .z.o;
// The /b is needed to show the simple results,
// as if just "dir" is used, the results can change between the two calls
(system "dir /b") ~ .test.evaluate["."; "\\dir /b"; "serialized"]`result;
(system "ls") ~ .test.evaluate["."; "\\ls"; "serialized"]`result];

expect pwd os command to return the current directory equivalent to system call:
(system "cd") ~ .test.evaluate["."; "\\cd"; "serialized"]`result

expect a to return a list of tables:
11h ~ type .test.evaluate["."; "\\a"; "serialized"]`result

expect c to return the console size:
6h ~ type .test.evaluate["."; "\\c"; "serialized"]`result

expect c 100 100 to set the console to 100 100:
.test.evaluate["."; "\\c 100 100"; "serialized"]`result;
100 100i ~ system "c"

expect p to provide the port:
system["p"] ~ .test.evaluate["."; "\\p"; "serialized"]`result

expect P to provide the precision:
system["P"] ~ .test.evaluate["."; "\\P"; "serialized"]`result

expect setting precision to 4 for it to be set to 4:
(system ["P"] ~ 4i) and (::) ~ .test.evaluate["."; "\\P 4"; "serialized"]`result

expect setting the precision to 0 sets it to max (same as 16):
(system ["P"] ~ 0i) and (::) ~ .test.evaluate["."; "\\P 0"; "serialized"]`result

// @TICKET KXI-9607
should work for non-default contexts
expect correct expression result
6 ~ .test.evaluate[".test"; "3+3"; "serialized"]`result

expect function to be compiled in the correct context
`foo ~ first @[;3] value .test.evaluate[".foo"; "fn:{3+3}"; "serialized"]`result

// @TICKET KXI-9607
should accept alternate values to indicate "."
expect correct expression result
.test.ctx: system "d";
system "d .ignore";
.test.evaluate["."; "myVal1: `first"; "serialized"]`result;
.test.evaluate["."; "myVal2: `second"; "serialized"]`result;
system "d " , string .test.ctx;
`first`second ~ get each `..myVal1`..myVal2;
after
delete myVal1 from `.;
delete myVal2 from `.;

// @TICKET KXI-9607
// @TICKET KXI-16397
should not remove things that look like comments
expect the /test to not be removed
// This needs the trim, because it returns "/test " on windows
trim[.test.evaluate["."; "\\echo /test"; "serialized"]`result] ~ enlist "/test"

// @TICKET KXI-9607
// @TICKET KXI-16397
should handle windows line endings
expect this to be treated as a single expression
.qu.compare[.test.evaluate["."; "(1\r\n\r\n 2 3)"; "serialized"]`result; 1 2 3]

// @TICKET KXI-9607
should maintain attributes regardless of semi-colon (KXAX-16342)
expect an attribute with no semi colons
`s ~ .test.evaluate["."; "\n" sv .test.attrLines; "serialized"]`result
expect an attribute with semi colons
`s ~ .test.evaluate["."; "\n" sv .test.attrLines ,\: ";"; "serialized"]`result
expect an attribute with no semi colons with two newlines
`s ~ .test.evaluate["."; "\n\n" sv .test.attrLines; "serialized"]`result
expect an attribute with semi colons with two newlines
`s ~ .test.evaluate["."; "\n\n" sv .test.attrLines ,\: ";"; "serialized"]`result
Loading