-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove core and re2 as dependency (#13)
* Make core a test-only dependency * Remove core as dependency in tests as well And further reduce the dependency cone. * Switch from re2 to re The dependency cone for re is much smaller than for re2. * CI: install also test dependencies * Fix regexp Re.Str.regexp_string does not do what I expected. Oops! * Remove reference to core in test/ * Remove Core from test/malformed.ml
- Loading branch information
Showing
8 changed files
with
137 additions
and
121 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
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
(library | ||
(name test_sarif) | ||
(libraries sarif core ppx_expect.common ppx_expect.config ppx_expect.config_types) | ||
(libraries sarif ppx_expect.common ppx_expect.config ppx_expect.config_types) | ||
(inline_tests (deps (glob_files data/*))) | ||
(preprocess (pps ppx_jane))) | ||
(preprocess (pps ppx_expect))) | ||
|
||
(include_subdirs unqualified) | ||
(include_subdirs unqualified) |
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 |
---|---|---|
@@ -1,130 +1,135 @@ | ||
open Core | ||
open Sarif | ||
|
||
let read_all file = | ||
let ic = open_in_bin file in | ||
let s = really_input_string ic (in_channel_length ic) in | ||
close_in ic; | ||
s | ||
|
||
let%expect_test "malformed_iso8601_date" = | ||
let json = In_channel.read_all "data/malformed.json" in | ||
let json = read_all "data/malformed.json" in | ||
let parsed_all = Sarif_v_2_1_0_j.sarif_json_schema_of_string json in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd_exn @@ parsed_all.runs in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd @@ parsed_all.runs in | ||
let parsed_run = Sarif_v_2_1_0_j.run_of_string run in | ||
let artifact = Sarif_v_2_1_0_j.string_of_artifact @@ List.nth_exn (Option.value_exn parsed_run.artifacts) 0 in | ||
let artifact = Sarif_v_2_1_0_j.string_of_artifact @@ List.nth (Option.get parsed_run.artifacts) 0 in | ||
let parsed_artifact = Sarif_v_2_1_0_j.artifact_of_string artifact in | ||
let res = Sarif_v_2_1_0_util.validate_artifact parsed_artifact in | ||
if res then print_endline "true" else print_endline "false"; | ||
[%expect {|false|}] | ||
|
||
let%expect_test "malformed_mime_type" = | ||
let json = In_channel.read_all "data/malformed.json" in | ||
let json = read_all "data/malformed.json" in | ||
let parsed_all = Sarif_v_2_1_0_j.sarif_json_schema_of_string json in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd_exn @@ parsed_all.runs in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd @@ parsed_all.runs in | ||
let parsed_run = Sarif_v_2_1_0_j.run_of_string run in | ||
let artifact = Sarif_v_2_1_0_j.string_of_artifact @@ List.nth_exn (Option.value_exn parsed_run.artifacts) 1 in | ||
let artifact = Sarif_v_2_1_0_j.string_of_artifact @@ List.nth (Option.get parsed_run.artifacts) 1 in | ||
let parsed_artifact = Sarif_v_2_1_0_j.artifact_of_string artifact in | ||
let res = Sarif_v_2_1_0_util.validate_artifact parsed_artifact in | ||
if res then print_endline "true" else print_endline "false"; | ||
[%expect {|false|}] | ||
|
||
let%expect_test "malformed_minimum_zero" = | ||
let json = In_channel.read_all "data/malformed.json" in | ||
let json = read_all "data/malformed.json" in | ||
let parsed_all = Sarif_v_2_1_0_j.sarif_json_schema_of_string json in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd_exn @@ parsed_all.runs in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd @@ parsed_all.runs in | ||
let parsed_run = Sarif_v_2_1_0_j.run_of_string run in | ||
let artifact = Sarif_v_2_1_0_j.string_of_artifact @@ List.nth_exn (Option.value_exn parsed_run.artifacts) 2 in | ||
let artifact = Sarif_v_2_1_0_j.string_of_artifact @@ List.nth (Option.get parsed_run.artifacts) 2 in | ||
let parsed_artifact = Sarif_v_2_1_0_j.artifact_of_string artifact in | ||
let res = Sarif_v_2_1_0_util.validate_artifact parsed_artifact in | ||
if res then print_endline "true" else print_endline "false"; | ||
[%expect {|false|}] | ||
|
||
let%expect_test "malformed_minimum_one" = | ||
let json = In_channel.read_all "data/malformed.json" in | ||
let json = read_all "data/malformed.json" in | ||
let parsed_all = Sarif_v_2_1_0_j.sarif_json_schema_of_string json in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd_exn @@ parsed_all.runs in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd @@ parsed_all.runs in | ||
let parsed_run = Sarif_v_2_1_0_j.run_of_string run in | ||
let result = Sarif_v_2_1_0_j.string_of_result @@ List.nth_exn (Option.value_exn parsed_run.results) 0 in | ||
let result = Sarif_v_2_1_0_j.string_of_result @@ List.nth (Option.get parsed_run.results) 0 in | ||
let parsed_result = Sarif_v_2_1_0_j.result_of_string result in | ||
let res = Sarif_v_2_1_0_util.validate_result parsed_result in | ||
if res then print_endline "true" else print_endline "false"; | ||
[%expect {|false|}] | ||
|
||
let%expect_test "malformed_minimum_minus_one" = | ||
let json = In_channel.read_all "data/malformed.json" in | ||
let json = read_all "data/malformed.json" in | ||
let parsed_all = Sarif_v_2_1_0_j.sarif_json_schema_of_string json in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd_exn @@ parsed_all.runs in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd @@ parsed_all.runs in | ||
let parsed_run = Sarif_v_2_1_0_j.run_of_string run in | ||
let artifact = Sarif_v_2_1_0_j.string_of_artifact @@ List.nth_exn (Option.value_exn parsed_run.artifacts) 3 in | ||
let artifact = Sarif_v_2_1_0_j.string_of_artifact @@ List.nth (Option.get parsed_run.artifacts) 3 in | ||
let parsed_artifact = Sarif_v_2_1_0_j.artifact_of_string artifact in | ||
let res = Sarif_v_2_1_0_util.validate_artifact parsed_artifact in | ||
if res then print_endline "true" else print_endline "false"; | ||
[%expect {|false|}] | ||
|
||
let%expect_test "malformed_guid" = | ||
let json = In_channel.read_all "data/malformed.json" in | ||
let json = read_all "data/malformed.json" in | ||
let parsed_all = Sarif_v_2_1_0_j.sarif_json_schema_of_string json in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd_exn @@ parsed_all.runs in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd @@ parsed_all.runs in | ||
let parsed_run = Sarif_v_2_1_0_j.run_of_string run in | ||
let result = Sarif_v_2_1_0_j.string_of_result @@ List.nth_exn (Option.value_exn parsed_run.results) 1 in | ||
let result = Sarif_v_2_1_0_j.string_of_result @@ List.nth (Option.get parsed_run.results) 1 in | ||
let parsed_result = Sarif_v_2_1_0_j.result_of_string result in | ||
let res = Sarif_v_2_1_0_util.validate_result parsed_result in | ||
if res then print_endline "true" else print_endline "false"; | ||
[%expect {|false|}] | ||
|
||
let%expect_test "malformed_dotted_quad_file" = | ||
let json = In_channel.read_all "data/malformed.json" in | ||
let json = read_all "data/malformed.json" in | ||
let parsed_all = Sarif_v_2_1_0_j.sarif_json_schema_of_string json in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd_exn @@ parsed_all.runs in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd @@ parsed_all.runs in | ||
let parsed_run = Sarif_v_2_1_0_j.run_of_string run in | ||
let taxonomies = Sarif_v_2_1_0_j.string_of_tool_component @@ List.hd_exn @@ Option.value_exn parsed_run.taxonomies in | ||
let taxonomies = Sarif_v_2_1_0_j.string_of_tool_component @@ List.hd @@ Option.get parsed_run.taxonomies in | ||
let parsed_taxonomies = Sarif_v_2_1_0_j.tool_component_of_string taxonomies in | ||
let res = Sarif_v_2_1_0_util.validate_tool_component parsed_taxonomies in | ||
if res then print_endline "true" else print_endline "false"; | ||
[%expect {|false|}] | ||
|
||
let%expect_test "malformed_language" = | ||
let json = In_channel.read_all "data/malformed1.json" in | ||
let json = read_all "data/malformed1.json" in | ||
let parsed_all = Sarif_v_2_1_0_j.sarif_json_schema_of_string json in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd_exn @@ parsed_all.runs in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd @@ parsed_all.runs in | ||
let parsed_run = Sarif_v_2_1_0_j.run_of_string run in | ||
let res = Sarif_v_2_1_0_util.validate_run parsed_run in | ||
if res then print_endline "true" else print_endline "false"; | ||
[%expect {|false|}] | ||
|
||
let%expect_test "malformed_none_unique" = | ||
let json = In_channel.read_all "data/malformed1.json" in | ||
let json = read_all "data/malformed1.json" in | ||
let parsed_all = Sarif_v_2_1_0_j.sarif_json_schema_of_string json in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd_exn @@ parsed_all.runs in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd @@ parsed_all.runs in | ||
let parsed_run = Sarif_v_2_1_0_j.run_of_string run in | ||
let result = Sarif_v_2_1_0_j.string_of_result @@ List.hd_exn @@ Option.value_exn parsed_run.results in | ||
let result = Sarif_v_2_1_0_j.string_of_result @@ List.hd @@ Option.get parsed_run.results in | ||
let parsed_result = Sarif_v_2_1_0_j.result_of_string result in | ||
let res = Sarif_v_2_1_0_util.validate_result parsed_result in | ||
if res then print_endline "true" else print_endline "false"; | ||
[%expect {|false|}] | ||
|
||
let%expect_test "malformed_rank" = | ||
let json = In_channel.read_all "data/malformed2.json" in | ||
let json = read_all "data/malformed2.json" in | ||
let parsed_all = Sarif_v_2_1_0_j.sarif_json_schema_of_string json in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd_exn @@ parsed_all.runs in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd @@ parsed_all.runs in | ||
let parsed_run = Sarif_v_2_1_0_j.run_of_string run in | ||
let result = Sarif_v_2_1_0_j.string_of_result @@ List.hd_exn @@ Option.value_exn parsed_run.results in | ||
let result = Sarif_v_2_1_0_j.string_of_result @@ List.hd @@ Option.get parsed_run.results in | ||
let parsed_result = Sarif_v_2_1_0_j.result_of_string result in | ||
let res = Sarif_v_2_1_0_util.validate_result parsed_result in | ||
if res then print_endline "true" else print_endline "false"; | ||
[%expect {|false|}] | ||
|
||
let%expect_test "malformed_uri" = | ||
let json = In_channel.read_all "data/malformed3.json" in | ||
let json = read_all "data/malformed3.json" in | ||
let parsed_all = Sarif_v_2_1_0_j.sarif_json_schema_of_string json in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd_exn @@ parsed_all.runs in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd @@ parsed_all.runs in | ||
let parsed_run = Sarif_v_2_1_0_j.run_of_string run in | ||
let result = Sarif_v_2_1_0_j.string_of_result @@ List.hd_exn @@ Option.value_exn parsed_run.results in | ||
let result = Sarif_v_2_1_0_j.string_of_result @@ List.hd @@ Option.get parsed_run.results in | ||
let parsed_result = Sarif_v_2_1_0_j.result_of_string result in | ||
let res = Sarif_v_2_1_0_util.validate_result parsed_result in | ||
if res then print_endline "true" else print_endline "false"; | ||
[%expect {|false|}] | ||
|
||
let%expect_test "malformed_list_min_size_one" = | ||
let json = In_channel.read_all "data/malformed4.json" in | ||
let json = read_all "data/malformed4.json" in | ||
let parsed_all = Sarif_v_2_1_0_j.sarif_json_schema_of_string json in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd_exn @@ parsed_all.runs in | ||
let run = Sarif_v_2_1_0_j.string_of_run @@ List.hd @@ parsed_all.runs in | ||
let parsed_run = Sarif_v_2_1_0_j.run_of_string run in | ||
let res = Sarif_v_2_1_0_util.validate_run parsed_run in | ||
if res then print_endline "true" else print_endline "false"; | ||
[%expect {|false|}] | ||
[%expect {|false|}] |
Oops, something went wrong.