mitoma/sver

sver can't reffer multi profiles on same sver.toml

kna opened this issue · 3 comments

kna commented

sver can't get file lists (and calc hash) for a profile which depends multi profiles on same sver.toml.
The root cause could be the following code:

sver/src/sver_repository.rs

Lines 190 to 193 in 205c8ce

if path_and_excludes.contains_key(path) {
debug!("already added. path:{}", path.to_string());
return Ok(());
}

It should check also a profile, I think.

The test code is here:

// repo layout
// .
// + test.txt
// + lib/sver.toml -> [default] dependency = ["lib/:prof1","lib/:prof2"], [prof1] dependency = ["test1.txt"], [prof2] dependency = ["test2.txt"]
#[test]
fn multiprofile_singledir() {
    initialize();

    // setup
    let repo = setup_test_repository();
    add_blob(&repo, "test1.txt", "hello".as_bytes());
    add_blob(&repo, "test2.txt", "world".as_bytes());
    add_blob(
        &repo,
        "lib/sver.toml",
        "
        [default]
        dependencies = [
            \"lib/:prof1\",
            \"lib/:prof2\",
        ]

        [prof1]
        dependencies = [
            \"test1.txt\",
        ]

        [prof2]
        dependencies = [
            \"test2.txt\",
        ]"
            .as_bytes(),
    );
    commit(&repo, "setup");

    // default
    {
        let sver_repo = SverRepository::new(&calc_target_path(&repo, "lib")).unwrap();

        // exercise
        let sources = sver_repo.list_sources().unwrap();
        let version = sver_repo.calc_version().unwrap();

        // verify
        assert_eq!(
            sources,
            vec!["lib/sver.toml", "test1.txt", "test2.txt"]
        );
        assert_eq!(
            version.version,
            "1a994876a6b773a73dd08ba8f176257f62ed9e95b5f034238c42da9702115ffe"
        );
    }
}

Thank you for your report.
This is a bug, so I fixed it in #63.

However, the hash value has changed from the test case you reported.
No problems?

kna commented

@mitoma
Thank you for fixing this so quickly!

I forgot that the hash(1a994876a6b773a73dd08ba8f176257f62ed9e95b5f034238c42da9702115ffe) was invalid because I couldn't calculate it.
Please update it.

#63 merged.