From 5dffba7f6a91fec7ca531bc193ffd7da8c418c3b Mon Sep 17 00:00:00 2001 From: vidhvath28 Date: Sun, 1 Sep 2024 10:07:50 +0530 Subject: [PATCH] GSOC2024 Submission --- README.md | 10 ++++++++-- spec/fixtures/reference_shards.nix | 12 ++++++++++++ spec/fixtures/test_shard.lock | 12 ++++++++++++ spec/integrated_spec.cr | 28 ++++++++++++++++++++++++++++ src/worker.cr | 4 ++-- 5 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 spec/fixtures/reference_shards.nix create mode 100644 spec/fixtures/test_shard.lock create mode 100644 spec/integrated_spec.cr diff --git a/README.md b/README.md index a6434f2..1c2cd8a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # crystal2nix -is a tool that makes it easier to manage and build Crystal projects using the Nix package manager +is a tool that makes it easier to manage and build Crystal projects using the Nix package manager ,currently supports git and mercurial sources . `crystal2nix` @@ -27,6 +27,12 @@ These tests can run offline and thus within the nix sandbox without network con These commands ensure that your changes are tested thoroughly before being pushed to the repository. +`make test-all` +These command helps use to test both the offline test cases and the integrated test cases together. + +`make test-online` +These command helps you to only test the integrated test cases . + ## Development @@ -35,7 +41,7 @@ We welcome all contributions, whether it's bug fixes, new features, or documenta ## Future plans In the future, we plan to add support for Fossil resources in the Crystal2Nix project -Add few integrity test case . +Add few more integrity test case . ## Contributing diff --git a/spec/fixtures/reference_shards.nix b/spec/fixtures/reference_shards.nix new file mode 100644 index 0000000..8444749 --- /dev/null +++ b/spec/fixtures/reference_shards.nix @@ -0,0 +1,12 @@ +{ + spectator = { + url = "https://gitlab.com/arctic-fox/spectator.git"; + rev = "v0.10.6"; + sha256 = "0w6mv1q44is2m19pyspkyiwm84h55nchsm4pp82gdbb0j9ylhckx"; + }; + version_from_shard = { + url = "https://github.com/hugopl/version_from_shard.git"; + rev = "v1.2.5"; + sha256 = "0xizj0q4rd541rwjbx04cjifc2gfx4l5v6q2y7gmd0ndjmkgb8ik"; + }; +} diff --git a/spec/fixtures/test_shard.lock b/spec/fixtures/test_shard.lock new file mode 100644 index 0000000..75c6146 --- /dev/null +++ b/spec/fixtures/test_shard.lock @@ -0,0 +1,12 @@ +version: 2.0 +shards: + spectator: + git: https://gitlab.com/arctic-fox/spectator.git + version: 0.10.6 + + version_from_shard: + git: https://github.com/hugopl/version_from_shard.git + version: 1.2.5 + + + diff --git a/spec/integrated_spec.cr b/spec/integrated_spec.cr new file mode 100644 index 0000000..e944a6b --- /dev/null +++ b/spec/integrated_spec.cr @@ -0,0 +1,28 @@ +require "./spec_helper" + +Spectator.describe Crystal2Nix::Worker, :online do + def run_and_validate_test(test_shard_lock, reference_shards_nix, generated_shards_nix) + SpecHelper.prepare_for_test(generated_shards_nix) + + Crystal2Nix::Worker.new(test_shard_lock).run + + generated_content = SpecHelper.read_file(generated_shards_nix) + reference_content = SpecHelper.read_file(reference_shards_nix) + + puts "Generated content:\n#{generated_content}" + puts "Reference content:\n#{reference_content}" + + expect(generated_content.strip).to eq(reference_content.strip) + ensure + SpecHelper.cleanup_file(generated_shards_nix) + end + + it "correctly generates the shards.nix file" do + run_and_validate_test( + "./spec/fixtures/test_shard.lock", + "./spec/fixtures/reference_shards.nix", + "./shards.nix" + ) + + end +end diff --git a/src/worker.cr b/src/worker.cr index 84d546b..c9e6d6b 100644 --- a/src/worker.cr +++ b/src/worker.cr @@ -66,7 +66,7 @@ module Crystal2Nix end else - log_message "Unsupported repository type for '#{key}': #{repo.type}. Currently supported types are: git, hg. Please update your configuration or contact support for further assistance." + log_message "Unsupported repository type for '#{key}': #{repo.type}. Currently supported types are: git, hg. ." break end @@ -89,7 +89,7 @@ module Crystal2Nix end File.rename(temp_file_path, SHARDS_NIX) - puts "Processing completed successfully with no errors." + puts "Processing completed successfully." end end end