Skip to content

Commit

Permalink
Merge pull request #30 from eNascimento178/Version3
Browse files Browse the repository at this point in the history
Add handling of ignored tests
  • Loading branch information
eNascimento178 authored Apr 2, 2024
2 parents e41ccb2 + 0e809ba commit cf71d8a
Show file tree
Hide file tree
Showing 23 changed files with 34 additions and 253 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*~
*~
**/tests/results.json
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ RUN apt-get update \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN wget https://www.jsoftware.com/download/j901/install/j901_linux64.tar.gz \
&& tar -xvf j901_linux64.tar.gz \
&& mv j901 /opt/j901 \
RUN wget https://www.jsoftware.com/download/j9.5/install/j9.5_linux64.tar.gz \
&& tar -xvf j9.5_linux64.tar.gz \
&& mv j9.5 /opt/j9.5 \
&& apt-get -y --purge remove wget ca-certificates \
&& rm -rf j901_linux64.tar.gz
&& rm -rf j9.5_linux64.tar.gz

RUN /opt/j901/bin/jconsole -js \
RUN /opt/j9.5/bin/jconsole -js \
"load'pacman'" \
"'update'jpkg''" \
"'install'jpkg'convert/json'" \
Expand Down
18 changes: 14 additions & 4 deletions bin/run.ijs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /opt/j901/bin/jconsole
#! /opt/j9.5/bin/jconsole

require'convert/json general/unittest'

Expand All @@ -10,12 +10,22 @@ report=: failure`success@.(1=#)
status=: (;:'fail pass') {~ [: *./ ('pass'-:1 0&{::)S:1
version=: <3

NB. REGEX verbs to circumvent the ignore flags on tests
temp_test_path =: < jpath '~temp/test.ijs'
repl_solution_path =: '[a-zA-Z0-9[-]*]*[.]ijs'&(jcwdpath rxapply)
repl_ignore_flag =: '_ignore ?=: ?[1-9]*'&( ( ('[1-9]+' ; '0')&rxrplc) rxapply)


main=: monad define
'slug indir outdir'=. _3{.ARGV NB. name args to vars and record cd
indir=. jpathsep indir
outdir=. jpathsep outdir
1!:44 indir NB. cd to indir
result=. }. }: <;._2 unittest indir,'test.ijs' NB. run tests

(repl_ignore_flag repl_solution_path 1!:1 < indir, 'test.ijs') 1!:2 temp_test_path NB. replace ignore flags and record tests in J's temp folder

result=. }. }: <;._2 unittest jpath '~temp/test.ijs' NB. run tests
1!:55 temp_test_path NB. deletes temporary test file

if. (1<#result) do.
if. 'Suite Error:'-:1{::result do. NB. error running test suite
Expand All @@ -30,7 +40,7 @@ main=: monad define
end. NB. else report pass/fail

'order tasks'=. |: > cutopen each cutopen 1!:1 < jpath '~temp/helper.txt' NB. get ordering and tasks numbers from temporary helper file
1!:55 < jpath '~user/temp/helper.txt' NB. deletes helper file
1!:55 < jpath '~temp/helper.txt' NB. deletes helper file
tasks=. |: ,: ,. (<'task_id') ,: <"0 tasks NB. tasks has shape 4 2 1 in order to simplify the merge


Expand All @@ -43,4 +53,4 @@ main=: monad define
exit 0
)

main''
main''
2 changes: 1 addition & 1 deletion bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ echo "${slug}: testing..."

# Run the tests for the provided implementation file and redirect stdout and
# stderr to capture it
test_output=$(/opt/j901/bin/jconsole bin/run.ijs "$slug" "$solution_dir/" "$output_dir/")
test_output=$(/opt/j9.5/bin/jconsole bin/run.ijs "$slug" "$solution_dir/" "$output_dir/")

jq . ${results_file} | sponge ${results_file}

Expand Down
2 changes: 1 addition & 1 deletion tests/all-fail/example.ijs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nuc_cnt=: [: +/ =/&'ACGT'
nuc_cnt=: [: +/ =/&'ACGT'
2 changes: 1 addition & 1 deletion tests/all-fail/nucleotide-count.ijs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nuc_cnt=: ]
nuc_cnt=: ]
34 changes: 0 additions & 34 deletions tests/all-fail/results.json

This file was deleted.

2 changes: 1 addition & 1 deletion tests/empty-file/example.ijs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nuc_cnt=: [: +/ =/&'ACGT'
nuc_cnt=: [: +/ =/&'ACGT'
34 changes: 0 additions & 34 deletions tests/empty-file/results.json

This file was deleted.

2 changes: 1 addition & 1 deletion tests/multiple-tasks/difference-of-squares.ijs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
square_of_sum=: [: *: +/ @ i. @ >:
sum_of_square=: [: +/ *: @ i. @ >:
difference_of_squares =: square_of_sum - sum_of_square
difference_of_squares =: square_of_sum - sum_of_square
54 changes: 0 additions & 54 deletions tests/multiple-tasks/results.json

This file was deleted.

2 changes: 1 addition & 1 deletion tests/partial-fail/example.ijs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nuc_cnt=: [: +/ =/&'ACGT'
nuc_cnt=: [: +/ =/&'ACGT'
2 changes: 1 addition & 1 deletion tests/partial-fail/nucleotide-count.ijs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nuc_cnt=: [: +/ =/&'ACGT'
nuc_cnt=: [: +/ =/&'ACGT'
31 changes: 0 additions & 31 deletions tests/partial-fail/results.json

This file was deleted.

2 changes: 1 addition & 1 deletion tests/success/example.ijs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nuc_cnt=: [: +/ =/&'ACGT'
nuc_cnt=: [: +/ =/&'ACGT'
2 changes: 1 addition & 1 deletion tests/success/nucleotide-count.ijs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nuc_cnt=: [: +/ =/&'ACGT'
nuc_cnt=: [: +/ =/&'ACGT'
30 changes: 0 additions & 30 deletions tests/success/results.json

This file was deleted.

2 changes: 1 addition & 1 deletion tests/syntax-error/example.ijs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nuc_cnt=: [: +/ =/&'ACGT'
nuc_cnt=: [: +/ =/&'ACGT'
2 changes: 1 addition & 1 deletion tests/syntax-error/expected_results.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 3,
"status": "error",
"message": "|syntax error: script\n| nuc_cnt=: ''<\n|[-0] nucleotide-count.ijs\n"
"message": "|syntax error in script, unexecutable fragment (noun verb)\n| nuc_cnt=: ''<\n|[-1] nucleotide-count.ijs\n"
}
2 changes: 1 addition & 1 deletion tests/syntax-error/nucleotide-count.ijs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nuc_cnt=: '' < NB. 'syntax error
nuc_cnt=: '' < NB. 'syntax error
5 changes: 0 additions & 5 deletions tests/syntax-error/results.json

This file was deleted.

42 changes: 0 additions & 42 deletions tests/unordered/results.json

This file was deleted.

2 changes: 1 addition & 1 deletion tests/unordered/rna-transcription.ijs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rna=: 'UGCA' {~ 'ACGT'&i.
rna=: 'UGCA' {~ 'ACGT'&i.

0 comments on commit cf71d8a

Please sign in to comment.