From b869c2772590ccc39f8d69a69f52b555fd4de802 Mon Sep 17 00:00:00 2001 From: Alexandr Kalinka Date: Tue, 27 Jun 2023 18:39:52 +0300 Subject: [PATCH 1/5] #37 - Upgrade to version 3 spec --- lib/extract_test_metadata.rb | 26 +++++++++++++++---- lib/minitest_ext/exercism_reporter.rb | 1 + lib/write_report.rb | 2 +- test/attacks_test.rb | 5 ++-- test/extract_metadata_test.rb | 21 ++++++++++------ test/fixtures/metadata/assert_equal.rb | 1 + test/fixtures/metadata/indices.rb | 1 + test/fixtures/metadata/skip.rb | 1 + test/fixtures/metadata/skip_comment.rb | 1 + test/test_runner_test.rb | 35 ++++++++++++++++---------- 10 files changed, 66 insertions(+), 28 deletions(-) diff --git a/lib/extract_test_metadata.rb b/lib/extract_test_metadata.rb index 4ba9fe5..556f6ca 100644 --- a/lib/extract_test_metadata.rb +++ b/lib/extract_test_metadata.rb @@ -19,7 +19,8 @@ def call test: test_identifier, name: test_name, test_code: test_code, - index: index + index: index, + task_id: task_id } end @@ -52,9 +53,6 @@ def test_name # - Plus an bits we've chosen to add back as the test_code part memoize def test_code - # Get the lines excluding the first (def) and last (end) - body_line_numbers = ((test_node.first_line + 1)..(test_node.last_line - 1)) - # Map through those lines, skipping any that were # part of assertions test_code = body_line_numbers.map do |idx| @@ -63,13 +61,26 @@ def test_code c = code_for_line(idx) # Only return if it's not a skip comment - c.start_with?(/\s*#\s*skip/) ? nil : c + c.start_with?(/\s*#\s*skip/, /\s*###\s*task_id/) ? nil : c end.compact.join("").rstrip # Align everything to the left as the final step clean_leading_whitespace(test_code) end + memoize + def task_id + body_line_numbers.map do |idx| + next if ignore_line_numbers.include?(idx) + + c = code_for_line(idx) + # Find a line started with `### task_id` and get the number + if c.start_with?(/\s*###\s*task_id/) + c.chomp.strip.delete('### task_id:').to_i + end + end.compact.first + end + # Remove the minimum amount of leading whitespace # from all lines def clean_leading_whitespace(multiline) @@ -82,5 +93,10 @@ def clean_leading_whitespace(multiline) def code_for_line(one_indexed_idx) filelines[one_indexed_idx - 1] end + + def body_line_numbers + # Get the lines excluding the first (def) and last (end) + ((test_node.first_line + 1)..(test_node.last_line - 1)) + end end end diff --git a/lib/minitest_ext/exercism_reporter.rb b/lib/minitest_ext/exercism_reporter.rb index 055763a..5befa2b 100644 --- a/lib/minitest_ext/exercism_reporter.rb +++ b/lib/minitest_ext/exercism_reporter.rb @@ -93,6 +93,7 @@ def to_h hash[:status] = status hash[:output] = output if attach_output? hash[:message] = message if attach_message? + hash[:task_id] = metadata[:task_id] end end diff --git a/lib/write_report.rb b/lib/write_report.rb index 4729ca6..b1cfe32 100644 --- a/lib/write_report.rb +++ b/lib/write_report.rb @@ -18,7 +18,7 @@ def call def json { - version: 2, + version: 3, status: status, message: message, tests: tests diff --git a/test/attacks_test.rb b/test/attacks_test.rb index 72986c7..727c320 100644 --- a/test/attacks_test.rb +++ b/test/attacks_test.rb @@ -4,7 +4,7 @@ class AttacksTest < Minitest::Test def test_large_output_is_truncated assert_fixture( :attack_large_output, { - version: 2, + version: 3, status: :fail, message: nil, tests: [ @@ -13,7 +13,8 @@ def test_large_output_is_truncated test_code: 'assert_equal "One for you, one for me.", TwoFer.two_fer', status: :fail, output: %(#{Array.new(500) { 'a' }.join}\n\n...Output was truncated. Please limit to 500 chars...), - message: "Expected: \"One for you, one for me.\"\n Actual: false" + message: "Expected: \"One for you, one for me.\"\n Actual: false", + task_id: nil } ] } diff --git a/test/extract_metadata_test.rb b/test/extract_metadata_test.rb index 759cac8..4878d43 100644 --- a/test/extract_metadata_test.rb +++ b/test/extract_metadata_test.rb @@ -7,7 +7,8 @@ def test_assert_equal test: "test_assert_equal_works_properly", name: "Assert equal works properly", test_code: %(some_result = TwoFer.two_fer\nassert_equal "One for you, one for me.", some_result), - index: 0 + index: 0, + task_id: 123 }] actual = TestRunner::ExtractMetadata.(File.expand_path("fixtures/metadata/assert_equal.rb", __dir__)) @@ -19,7 +20,8 @@ def test_no_skips test: "test_skip_works_properly", name: "Skip works properly", test_code: "something = \"Something\"\nassert something.present?", - index: 0 + index: 0, + task_id: 456 }] actual = TestRunner::ExtractMetadata.(File.expand_path("fixtures/metadata/skip.rb", __dir__)) @@ -31,7 +33,8 @@ def test_no_skip_comments test: "test_skip_works_properly", name: "Skip works properly", test_code: "something = \"Something\"\nassert something.present?", - index: 0 + index: 0, + task_id: 789 }] actual = TestRunner::ExtractMetadata.(File.expand_path("fixtures/metadata/skip_comment.rb", __dir__)) @@ -44,25 +47,29 @@ def test_extracting_indices test: "test_zebra", name: "Zebra", test_code: %(some_result = TwoFer.two_fer("zebra")\nassert_equal "One for you, one for zebra.", some_result), - index: 0 + index: 0, + task_id: 789 }, { test: "test_anaconda", name: "Anaconda", test_code: %(some_result = TwoFer.two_fer("anaconda")\nassert_equal "One for you, one for anaconda.", some_result), - index: 1 + index: 1, + task_id: nil }, { test: "test_gorilla", name: "Gorilla", test_code: %(some_result = TwoFer.two_fer("gorilla")\nassert_equal "One for you, one for gorilla.", some_result), - index: 2 + index: 2, + task_id: nil }, { test: "test_boa", name: "Boa", test_code: %(some_result = TwoFer.two_fer("boa")\nassert_equal "One for you, one for boa.", some_result), - index: 3 + index: 3, + task_id: nil } ] diff --git a/test/fixtures/metadata/assert_equal.rb b/test/fixtures/metadata/assert_equal.rb index f3e1324..36542d5 100644 --- a/test/fixtures/metadata/assert_equal.rb +++ b/test/fixtures/metadata/assert_equal.rb @@ -1,5 +1,6 @@ class SomeTest < Minitest::Test def test_assert_equal_works_properly + ### task_id: 123 some_result = TwoFer.two_fer assert_equal "One for you, one for me.", some_result end diff --git a/test/fixtures/metadata/indices.rb b/test/fixtures/metadata/indices.rb index 77046dd..3c09171 100644 --- a/test/fixtures/metadata/indices.rb +++ b/test/fixtures/metadata/indices.rb @@ -1,5 +1,6 @@ class SomeTest < Minitest::Test def test_zebra + ### task_id: 789 some_result = TwoFer.two_fer("zebra") assert_equal "One for you, one for zebra.", some_result end diff --git a/test/fixtures/metadata/skip.rb b/test/fixtures/metadata/skip.rb index 4395e78..621a85d 100644 --- a/test/fixtures/metadata/skip.rb +++ b/test/fixtures/metadata/skip.rb @@ -1,5 +1,6 @@ class SomeTest < Minitest::Test def test_skip_works_properly + ### task_id: 456 skip something = "Something" assert something.present? diff --git a/test/fixtures/metadata/skip_comment.rb b/test/fixtures/metadata/skip_comment.rb index 0957860..f1798ba 100644 --- a/test/fixtures/metadata/skip_comment.rb +++ b/test/fixtures/metadata/skip_comment.rb @@ -1,5 +1,6 @@ class SomeTest < Minitest::Test def test_skip_works_properly + ### task_id: 789 #skip # skip something = "Something" diff --git a/test/test_runner_test.rb b/test/test_runner_test.rb index c868a68..c0f6770 100644 --- a/test/test_runner_test.rb +++ b/test/test_runner_test.rb @@ -5,24 +5,27 @@ def test_pass assert_fixture( :pass, { - version: 2, + version: 3, status: :pass, message: nil, tests: [ { name: "No name given", status: :pass, - test_code: %(assert_equal "One for you, one for me.", TwoFer.two_fer) + test_code: %(assert_equal "One for you, one for me.", TwoFer.two_fer), + task_id: nil }, { name: 'A name given', test_code: 'assert_equal "One for Alice, one for me.", TwoFer.two_fer("Alice")', - status: :pass + status: :pass, + task_id: nil }, { name: "Another name given", status: :pass, - test_code: 'assert_equal "One for Bob, one for me.", TwoFer.two_fer("Bob")' + test_code: 'assert_equal "One for Bob, one for me.", TwoFer.two_fer("Bob")', + task_id: nil } ] } @@ -33,19 +36,21 @@ def test_pass_ruby_3 assert_fixture( :pass_ruby_3_syntax, { - version: 2, + version: 3, status: :pass, message: nil, tests: [ { name: "Rightward assign", status: :pass, - test_code: %(assert_equal Ruby3Syntax.rightward_assign, 'is fun') + test_code: %(assert_equal Ruby3Syntax.rightward_assign, 'is fun'), + task_id: nil }, { name: "Endless method def", status: :pass, - test_code: %(assert_equal Ruby3Syntax.endless_methods, 'are fun') + test_code: %(assert_equal Ruby3Syntax.endless_methods, 'are fun'), + task_id: nil } ] } @@ -55,7 +60,7 @@ def test_pass_ruby_3 def test_fail assert_fixture( :fail, { - version: 2, + version: 3, status: :fail, message: nil, tests: [ @@ -64,19 +69,22 @@ def test_fail test_code: %(assert_equal "One for you, one for me.", TwoFer.two_fer), status: :fail, message: %(Expected: \"One for you, one for me.\"\n Actual: \"One for fred, one for me.\"), - output: "The name is fred.\nHere's another line.\n" + output: "The name is fred.\nHere's another line.\n", + task_id: nil }, { name: "A name given", test_code: 'assert_equal "One for Alice, one for me.", TwoFer.two_fer("Alice")', status: :pass, - output: "The name is Alice.\nHere's another line.\n" + output: "The name is Alice.\nHere's another line.\n", + task_id: nil }, { name: "Another name given", test_code: 'assert_equal "One for Bob, one for me.", TwoFer.two_fer("Bob")', status: :pass, - output: "The name is Bob.\nHere's another line.\n" + output: "The name is Bob.\nHere's another line.\n", + task_id: nil } ] } @@ -95,7 +103,7 @@ def test_deep_exception assert_fixture( :deep_exception, { - version: 2, + version: 3, status: :fail, message: nil, tests: [ @@ -103,7 +111,8 @@ def test_deep_exception name: "No name given", test_code: 'assert_equal "One for you, one for me.", TwoFer.two_fer', status: :error, - message: message + message: message, + task_id: nil } ] } From 40c9b06376674adca52e3e359e352322cc4d5cf6 Mon Sep 17 00:00:00 2001 From: Alexandr Kalinka Date: Tue, 4 Jul 2023 17:47:40 +0300 Subject: [PATCH 2/5] #37 - fix rubocop warning --- lib/extract_test_metadata.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/extract_test_metadata.rb b/lib/extract_test_metadata.rb index 556f6ca..4e26d73 100644 --- a/lib/extract_test_metadata.rb +++ b/lib/extract_test_metadata.rb @@ -75,9 +75,8 @@ def task_id c = code_for_line(idx) # Find a line started with `### task_id` and get the number - if c.start_with?(/\s*###\s*task_id/) - c.chomp.strip.delete('### task_id:').to_i - end + ch_task_id = /\s*###\s*task_id/ + c.chomp.strip.delete('### task_id:').to_i if c.start_with?(ch_task_id) end.compact.first end From 4bfd0fb38f452502ef8bf9243c5cdb0af6d60a59 Mon Sep 17 00:00:00 2001 From: Alexandr Kalinka Date: Wed, 14 Feb 2024 18:25:30 +0300 Subject: [PATCH 3/5] #37 - fix json tests fixtures --- tests/attack_large_output/expected_results.json | 2 +- tests/deep_exception/expected_results.json | 2 +- tests/empty/expected_results.json | 2 +- tests/exception/expected_results.json | 2 +- tests/fail/expected_results.json | 2 +- tests/input/expected_results.json | 2 +- tests/metadata/expected_results.json | 2 +- tests/pass/expected_results.json | 2 +- tests/pass_ruby_3_syntax/expected_results.json | 2 +- tests/syntax_error_in_code/expected_results.json | 2 +- tests/syntax_error_in_tests/expected_results.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/attack_large_output/expected_results.json b/tests/attack_large_output/expected_results.json index 17e441c..e669b6a 100644 --- a/tests/attack_large_output/expected_results.json +++ b/tests/attack_large_output/expected_results.json @@ -1 +1 @@ -{"version":2,"status":"pass","message":null,"tests":[]} +{"version":3,"status":"pass","message":null,"tests":[]} diff --git a/tests/deep_exception/expected_results.json b/tests/deep_exception/expected_results.json index 17e441c..e669b6a 100644 --- a/tests/deep_exception/expected_results.json +++ b/tests/deep_exception/expected_results.json @@ -1 +1 @@ -{"version":2,"status":"pass","message":null,"tests":[]} +{"version":3,"status":"pass","message":null,"tests":[]} diff --git a/tests/empty/expected_results.json b/tests/empty/expected_results.json index c880a92..5f9404a 100644 --- a/tests/empty/expected_results.json +++ b/tests/empty/expected_results.json @@ -1 +1 @@ -{"version":2,"status":"fail","message":null,"tests":[{"name":"No name given","test_code":"assert_equal \"One for you, one for me.\", TwoFer.two_fer","status":"error","message":"NameError: uninitialized constant TwoFerTest::TwoFer\n\nTraceback (most recent call first):\n Line 7:in `test_no_name_given'"}]} +{"version":3,"status":"fail","message":null,"tests":[{"name":"No name given","test_code":"assert_equal \"One for you, one for me.\", TwoFer.two_fer","status":"error","message":"NameError: uninitialized constant TwoFerTest::TwoFer\n\nTraceback (most recent call first):\n Line 7:in `test_no_name_given'","task_id":null}]} diff --git a/tests/exception/expected_results.json b/tests/exception/expected_results.json index 17e441c..e669b6a 100644 --- a/tests/exception/expected_results.json +++ b/tests/exception/expected_results.json @@ -1 +1 @@ -{"version":2,"status":"pass","message":null,"tests":[]} +{"version":3,"status":"pass","message":null,"tests":[]} diff --git a/tests/fail/expected_results.json b/tests/fail/expected_results.json index 17e441c..e669b6a 100644 --- a/tests/fail/expected_results.json +++ b/tests/fail/expected_results.json @@ -1 +1 @@ -{"version":2,"status":"pass","message":null,"tests":[]} +{"version":3,"status":"pass","message":null,"tests":[]} diff --git a/tests/input/expected_results.json b/tests/input/expected_results.json index ad1c9e6..8bdf182 100644 --- a/tests/input/expected_results.json +++ b/tests/input/expected_results.json @@ -1 +1 @@ -{"version":2,"status":"fail","message":null,"tests":[{"name":"No name given","test_code":"assert_equal \"One for you, one for me.\", TwoFer.two_fer","status":"fail","output":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n\n...Output was truncated. Please limit to 500 chars...","message":"Expected: \"One for you, one for me.\"\n Actual: false"}]} +{"version":3,"status":"fail","message":null,"tests":[{"name":"No name given","test_code":"assert_equal \"One for you, one for me.\", TwoFer.two_fer","status":"fail","output":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n\n...Output was truncated. Please limit to 500 chars...","message":"Expected: \"One for you, one for me.\"\n Actual: false","task_id":null}]} diff --git a/tests/metadata/expected_results.json b/tests/metadata/expected_results.json index 17e441c..e669b6a 100644 --- a/tests/metadata/expected_results.json +++ b/tests/metadata/expected_results.json @@ -1 +1 @@ -{"version":2,"status":"pass","message":null,"tests":[]} +{"version":3,"status":"pass","message":null,"tests":[]} diff --git a/tests/pass/expected_results.json b/tests/pass/expected_results.json index 17e441c..e669b6a 100644 --- a/tests/pass/expected_results.json +++ b/tests/pass/expected_results.json @@ -1 +1 @@ -{"version":2,"status":"pass","message":null,"tests":[]} +{"version":3,"status":"pass","message":null,"tests":[]} diff --git a/tests/pass_ruby_3_syntax/expected_results.json b/tests/pass_ruby_3_syntax/expected_results.json index 17e441c..e669b6a 100644 --- a/tests/pass_ruby_3_syntax/expected_results.json +++ b/tests/pass_ruby_3_syntax/expected_results.json @@ -1 +1 @@ -{"version":2,"status":"pass","message":null,"tests":[]} +{"version":3,"status":"pass","message":null,"tests":[]} diff --git a/tests/syntax_error_in_code/expected_results.json b/tests/syntax_error_in_code/expected_results.json index 17e441c..e669b6a 100644 --- a/tests/syntax_error_in_code/expected_results.json +++ b/tests/syntax_error_in_code/expected_results.json @@ -1 +1 @@ -{"version":2,"status":"pass","message":null,"tests":[]} +{"version":3,"status":"pass","message":null,"tests":[]} diff --git a/tests/syntax_error_in_tests/expected_results.json b/tests/syntax_error_in_tests/expected_results.json index 17e441c..e669b6a 100644 --- a/tests/syntax_error_in_tests/expected_results.json +++ b/tests/syntax_error_in_tests/expected_results.json @@ -1 +1 @@ -{"version":2,"status":"pass","message":null,"tests":[]} +{"version":3,"status":"pass","message":null,"tests":[]} From d1ba3aadbbf0ba2502dcc8d64bfcf0f5abe7572c Mon Sep 17 00:00:00 2001 From: Alexandr Kalinka Date: Tue, 9 Apr 2024 10:34:39 +0300 Subject: [PATCH 4/5] #37 - memoize body_line_numbers method --- lib/extract_test_metadata.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/extract_test_metadata.rb b/lib/extract_test_metadata.rb index 66c666a..74413d2 100644 --- a/lib/extract_test_metadata.rb +++ b/lib/extract_test_metadata.rb @@ -93,6 +93,7 @@ def code_for_line(one_indexed_idx) filelines[one_indexed_idx - 1] end + memoize def body_line_numbers # Get the lines excluding the first (def) and last (end) ((test_node.first_line + 1)..(test_node.last_line - 1)) From a926f3612e7564a110a0af19e7c0c2ab535f93c8 Mon Sep 17 00:00:00 2001 From: Alexandr Kalinka Date: Thu, 11 Apr 2024 10:06:12 +0300 Subject: [PATCH 5/5] #37 - fix Smoke tests --- tests/attack_large_output/expected_results.json | 2 +- tests/benchmarks/expected_results.json | 2 +- tests/deep_exception/expected_results.json | 2 +- tests/fail/expected_results.json | 2 +- tests/input/two_fer.rb | 6 ++++++ tests/input/two_fer_test.rb | 9 +++++++++ tests/metadata/expected_results.json | 2 +- tests/pass/expected_results.json | 2 +- tests/pass_ruby_3_syntax/expected_results.json | 2 +- 9 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 tests/input/two_fer.rb create mode 100644 tests/input/two_fer_test.rb diff --git a/tests/attack_large_output/expected_results.json b/tests/attack_large_output/expected_results.json index 6a7354b..8bdf182 100644 --- a/tests/attack_large_output/expected_results.json +++ b/tests/attack_large_output/expected_results.json @@ -1 +1 @@ -{"version":3,"status":"fail","message":null,"tests":[{"name":"No name given","test_code":"assert_equal \"One for you, one for me.\", TwoFer.two_fer","status":"fail","output":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n\n...Output was truncated. Please limit to 500 chars...","message":"Expected: \"One for you, one for me.\"\n Actual: false"}]} +{"version":3,"status":"fail","message":null,"tests":[{"name":"No name given","test_code":"assert_equal \"One for you, one for me.\", TwoFer.two_fer","status":"fail","output":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n\n...Output was truncated. Please limit to 500 chars...","message":"Expected: \"One for you, one for me.\"\n Actual: false","task_id":null}]} diff --git a/tests/benchmarks/expected_results.json b/tests/benchmarks/expected_results.json index 60e6acd..3972ee8 100644 --- a/tests/benchmarks/expected_results.json +++ b/tests/benchmarks/expected_results.json @@ -1 +1 @@ -{"version":2,"status":"pass","message":null,"tests":[{"name":"No name given","test_code":"assert_equal \"One for you, one for me.\", TwoFer.two_fer","status":"pass"},{"name":"A name given","test_code":"assert_equal \"One for Alice, one for me.\", TwoFer.two_fer(\"Alice\")","status":"pass"},{"name":"Another name given","test_code":"assert_equal \"One for Bob, one for me.\", TwoFer.two_fer(\"Bob\")","status":"pass"}]} +{"version":3,"status":"pass","message":null,"tests":[{"name":"No name given","test_code":"assert_equal \"One for you, one for me.\", TwoFer.two_fer","status":"pass","task_id":null},{"name":"A name given","test_code":"assert_equal \"One for Alice, one for me.\", TwoFer.two_fer(\"Alice\")","status":"pass","task_id":null},{"name":"Another name given","test_code":"assert_equal \"One for Bob, one for me.\", TwoFer.two_fer(\"Bob\")","status":"pass","task_id":null}]} diff --git a/tests/deep_exception/expected_results.json b/tests/deep_exception/expected_results.json index c8ade06..285bc43 100644 --- a/tests/deep_exception/expected_results.json +++ b/tests/deep_exception/expected_results.json @@ -1 +1 @@ -{"version":3,"status":"fail","message":null,"tests":[{"name":"No name given","test_code":"assert_equal \"One for you, one for me.\", TwoFer.two_fer","status":"error","message":"NoMethodError: undefined method `non_existant_method' for nil\n\nTraceback (most recent call first):\n Line 8:in `work_out_name'\n Line 3:in `two_fer'"}]} +{"version":3,"status":"fail","message":null,"tests":[{"name":"No name given","test_code":"assert_equal \"One for you, one for me.\", TwoFer.two_fer","status":"error","message":"NoMethodError: undefined method `non_existant_method' for nil\n\nTraceback (most recent call first):\n Line 8:in `work_out_name'\n Line 3:in `two_fer'","task_id":null}]} diff --git a/tests/fail/expected_results.json b/tests/fail/expected_results.json index 3536cbc..2806737 100644 --- a/tests/fail/expected_results.json +++ b/tests/fail/expected_results.json @@ -1 +1 @@ -{"version":3,"status":"fail","message":null,"tests":[{"name":"No name given","test_code":"assert_equal \"One for you, one for me.\", TwoFer.two_fer","status":"fail","output":"The name is fred.\nHere's another line.\n","message":"Expected: \"One for you, one for me.\"\n Actual: \"One for fred, one for me.\""},{"name":"A name given","test_code":"assert_equal \"One for Alice, one for me.\", TwoFer.two_fer(\"Alice\")","status":"pass","output":"The name is Alice.\nHere's another line.\n"},{"name":"Another name given","test_code":"assert_equal \"One for Bob, one for me.\", TwoFer.two_fer(\"Bob\")","status":"pass","output":"The name is Bob.\nHere's another line.\n"}]} +{"version":3,"status":"fail","message":null,"tests":[{"name":"No name given","test_code":"assert_equal \"One for you, one for me.\", TwoFer.two_fer","status":"fail","output":"The name is fred.\nHere's another line.\n","message":"Expected: \"One for you, one for me.\"\n Actual: \"One for fred, one for me.\"","task_id":null},{"name":"A name given","test_code":"assert_equal \"One for Alice, one for me.\", TwoFer.two_fer(\"Alice\")","status":"pass","output":"The name is Alice.\nHere's another line.\n","task_id":null},{"name":"Another name given","test_code":"assert_equal \"One for Bob, one for me.\", TwoFer.two_fer(\"Bob\")","status":"pass","output":"The name is Bob.\nHere's another line.\n","task_id":null}]} diff --git a/tests/input/two_fer.rb b/tests/input/two_fer.rb new file mode 100644 index 0000000..9fef9b3 --- /dev/null +++ b/tests/input/two_fer.rb @@ -0,0 +1,6 @@ +class TwoFer + def self.two_fer(_name = "you") + debug Array.new(1000) { "a" }.join + false + end +end diff --git a/tests/input/two_fer_test.rb b/tests/input/two_fer_test.rb new file mode 100644 index 0000000..a41ad59 --- /dev/null +++ b/tests/input/two_fer_test.rb @@ -0,0 +1,9 @@ +require 'minitest/autorun' +require_relative 'two_fer' + +# Common test data version: 1.2.0 4fc1acb +class TwoFerTest < Minitest::Test + def test_no_name_given + assert_equal "One for you, one for me.", TwoFer.two_fer + end +end diff --git a/tests/metadata/expected_results.json b/tests/metadata/expected_results.json index 3dbc3c1..f24f6f1 100644 --- a/tests/metadata/expected_results.json +++ b/tests/metadata/expected_results.json @@ -1 +1 @@ -{"version":3,"status":"fail","message":null,"tests":[{"name":"Assert equal works properly","test_code":"some_result = TwoFer.two_fer\nassert_equal \"One for you, one for me.\", some_result","status":"error","message":"NameError: uninitialized constant SomeTest::TwoFer\n\nTraceback (most recent call first):\n Line 3:in `test_assert_equal_works_properly'"},{"name":"Skip works properly","test_code":"something = \"Something\"\nassert something.present?","status":"error","message":"NoMethodError: undefined method `present?' for an instance of String\n\nTraceback (most recent call first):\n Line 5:in `test_skip_works_properly'"},{"name":"Zebra","test_code":"some_result = TwoFer.two_fer(\"zebra\")\nassert_equal \"One for you, one for zebra.\", some_result","status":"error","message":"NameError: uninitialized constant SomeTest::TwoFer\n\nTraceback (most recent call first):\n Line 3:in `test_zebra'"},{"name":"Anaconda","test_code":"some_result = TwoFer.two_fer(\"anaconda\")\nassert_equal \"One for you, one for anaconda.\", some_result","status":"error","message":"NameError: uninitialized constant SomeTest::TwoFer\n\nTraceback (most recent call first):\n Line 8:in `test_anaconda'"},{"name":"Gorilla","test_code":"some_result = TwoFer.two_fer(\"gorilla\")\nassert_equal \"One for you, one for gorilla.\", some_result","status":"error","message":"NameError: uninitialized constant SomeTest::TwoFer\n\nTraceback (most recent call first):\n Line 13:in `test_gorilla'"},{"name":"Boa","test_code":"some_result = TwoFer.two_fer(\"boa\")\nassert_equal \"One for you, one for boa.\", some_result","status":"error","message":"NameError: uninitialized constant SomeTest::TwoFer\n\nTraceback (most recent call first):\n Line 18:in `test_boa'"}]} +{"version":3,"status":"fail","message":null,"tests":[{"name":"Assert equal works properly","test_code":"some_result = TwoFer.two_fer\nassert_equal \"One for you, one for me.\", some_result","status":"error","message":"NameError: uninitialized constant SomeTest::TwoFer\n\nTraceback (most recent call first):\n Line 3:in `test_assert_equal_works_properly'","task_id":null},{"name":"Skip works properly","test_code":"something = \"Something\"\nassert something.present?","status":"error","message":"NoMethodError: undefined method `present?' for an instance of String\n\nTraceback (most recent call first):\n Line 5:in `test_skip_works_properly'","task_id":null},{"name":"Zebra","test_code":"some_result = TwoFer.two_fer(\"zebra\")\nassert_equal \"One for you, one for zebra.\", some_result","status":"error","message":"NameError: uninitialized constant SomeTest::TwoFer\n\nTraceback (most recent call first):\n Line 3:in `test_zebra'","task_id":null},{"name":"Anaconda","test_code":"some_result = TwoFer.two_fer(\"anaconda\")\nassert_equal \"One for you, one for anaconda.\", some_result","status":"error","message":"NameError: uninitialized constant SomeTest::TwoFer\n\nTraceback (most recent call first):\n Line 8:in `test_anaconda'","task_id":null},{"name":"Gorilla","test_code":"some_result = TwoFer.two_fer(\"gorilla\")\nassert_equal \"One for you, one for gorilla.\", some_result","status":"error","message":"NameError: uninitialized constant SomeTest::TwoFer\n\nTraceback (most recent call first):\n Line 13:in `test_gorilla'","task_id":null},{"name":"Boa","test_code":"some_result = TwoFer.two_fer(\"boa\")\nassert_equal \"One for you, one for boa.\", some_result","status":"error","message":"NameError: uninitialized constant SomeTest::TwoFer\n\nTraceback (most recent call first):\n Line 18:in `test_boa'","task_id":null}]} diff --git a/tests/pass/expected_results.json b/tests/pass/expected_results.json index 2489023..3972ee8 100644 --- a/tests/pass/expected_results.json +++ b/tests/pass/expected_results.json @@ -1 +1 @@ -{"version":3,"status":"pass","message":null,"tests":[{"name":"No name given","test_code":"assert_equal \"One for you, one for me.\", TwoFer.two_fer","status":"pass"},{"name":"A name given","test_code":"assert_equal \"One for Alice, one for me.\", TwoFer.two_fer(\"Alice\")","status":"pass"},{"name":"Another name given","test_code":"assert_equal \"One for Bob, one for me.\", TwoFer.two_fer(\"Bob\")","status":"pass"}]} +{"version":3,"status":"pass","message":null,"tests":[{"name":"No name given","test_code":"assert_equal \"One for you, one for me.\", TwoFer.two_fer","status":"pass","task_id":null},{"name":"A name given","test_code":"assert_equal \"One for Alice, one for me.\", TwoFer.two_fer(\"Alice\")","status":"pass","task_id":null},{"name":"Another name given","test_code":"assert_equal \"One for Bob, one for me.\", TwoFer.two_fer(\"Bob\")","status":"pass","task_id":null}]} diff --git a/tests/pass_ruby_3_syntax/expected_results.json b/tests/pass_ruby_3_syntax/expected_results.json index 783eaab..0b94ec3 100644 --- a/tests/pass_ruby_3_syntax/expected_results.json +++ b/tests/pass_ruby_3_syntax/expected_results.json @@ -1 +1 @@ -{"version":3,"status":"pass","message":null,"tests":[{"name":"Rightward assign","test_code":"assert_equal Ruby3Syntax.rightward_assign, 'is fun'","status":"pass"},{"name":"Endless method def","test_code":"assert_equal Ruby3Syntax.endless_methods, 'are fun'","status":"pass"}]} +{"version":3,"status":"pass","message":null,"tests":[{"name":"Rightward assign","test_code":"assert_equal Ruby3Syntax.rightward_assign, 'is fun'","status":"pass","task_id":null},{"name":"Endless method def","test_code":"assert_equal Ruby3Syntax.endless_methods, 'are fun'","status":"pass","task_id":null}]}