Skip to content

Commit

Permalink
test: fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
antonbaliasnikov committed Feb 13, 2024
1 parent 9a2a526 commit 21ae1cc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 49 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
action_fail_on_inconclusive: true

build-and-test-macos:
needs: check-formatting
strategy:
matrix:
include:
Expand All @@ -96,6 +97,8 @@ jobs:
rm -rf ${{ github.workspace }}/*
- name: Checkout source
uses: actions/checkout@v4
- name: Prepare environment
run: brew install cmake ninja
- name: Build
run: cargo build --release
- name: Test
Expand All @@ -104,7 +107,7 @@ jobs:
cargo test --no-fail-fast -- -Z unstable-options --format json | cargo2junit | tee "${UNIT_TESTS_RESULTS_XML}"
- name: Upload test results
if: always()
uses: EnricoMi/publish-unit-test-result-action@v2
uses: EnricoMi/publish-unit-test-result-action/composite@v2
with:
check_name: ${{ matrix.name }} Unit Tests Results
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
12 changes: 8 additions & 4 deletions tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ fn build_without_clone() -> anyhow::Result<()> {
Ok(())
}

/// Tests the build process of the LLVM repository.
/// Tests the clone, build, and clean process of the LLVM repository.
///
/// This test verifies that the LLVM repository can be successfully cloned and built.
/// This test verifies that the LLVM repository can be successfully cloned, built, and cleaned.
///
/// # Errors
///
/// Returns an error if any of the test assertions fail or if there is an error while executing
/// the build commands.
/// the build or clean commands.
///
/// # Returns
///
/// Returns `Ok(())` if the test passes.
#[rstest]
#[timeout(std::time::Duration::from_secs(1200))]
fn build() -> anyhow::Result<()> {
fn clone_build_and_clean() -> anyhow::Result<()> {
let mut cmd = Command::cargo_bin(constants::ZKEVM_LLVM)?;
let file = assert_fs::NamedTempFile::new(constants::LLVM_LOCK_FILE)?;
let path = file.parent().unwrap();
Expand All @@ -66,6 +66,10 @@ fn build() -> anyhow::Result<()> {
.assert()
.success()
.stdout(predicate::str::is_match("Installing:.*").unwrap());
let mut clean_cmd = Command::cargo_bin(constants::ZKEVM_LLVM)?;
clean_cmd.current_dir(path);
clean_cmd.arg("clean");
clean_cmd.assert().success();
Ok(())
}

Expand Down
6 changes: 3 additions & 3 deletions tests/checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ fn checkout_without_lockfile() -> anyhow::Result<()> {
let path = file.parent().unwrap();
cmd.current_dir(path);
cmd.arg("checkout");
cmd.assert()
.failure()
.stderr(predicate::str::contains("No such file or directory"));
cmd.assert().failure().stderr(predicate::str::contains(
"Error: Error opening \"LLVM.lock\" file",
));
Ok(())
}
38 changes: 0 additions & 38 deletions tests/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,3 @@ fn clean_without_clone() -> anyhow::Result<()> {
));
Ok(())
}

/// Tests the clone, build, and clean process of the LLVM repository.
///
/// This test verifies that the LLVM repository can be successfully cloned, built, and cleaned.
///
/// # Errors
///
/// Returns an error if any of the test assertions fail or if there is an error while executing
/// the build or clean commands.
///
/// # Returns
///
/// Returns `Ok(())` if the test passes.
#[rstest]
fn clone_build_and_clean() -> anyhow::Result<()> {
let mut clone_cmd = Command::cargo_bin(constants::ZKEVM_LLVM)?;
let file = assert_fs::NamedTempFile::new(constants::LLVM_LOCK_FILE)?;
let path = file.parent().unwrap();
clone_cmd.current_dir(path);
file.write_str(&*format!("url = \"{}\"", constants::ERA_LLVM_REPO_URL))?;
clone_cmd.arg("clone");
clone_cmd
.assert()
.success()
.stderr(predicate::str::is_match(".*Updating files:.*100%.*done").unwrap());
let mut build_cmd = Command::cargo_bin(constants::ZKEVM_LLVM)?;
build_cmd.current_dir(path);
build_cmd.arg("build").env("DRY_RUN", "true");
build_cmd
.assert()
.success()
.stdout(predicate::str::contains("Install the project..."));
let mut clean_cmd = Command::cargo_bin(constants::ZKEVM_LLVM)?;
clean_cmd.current_dir(path);
clean_cmd.arg("clean");
clean_cmd.assert().success();
Ok(())
}
6 changes: 3 additions & 3 deletions tests/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ fn clone_without_lockfile() -> anyhow::Result<()> {
let path = file.parent().unwrap();
cmd.current_dir(path);
cmd.arg("clone");
cmd.assert()
.failure()
.stderr(predicate::str::contains("No such file or directory"));
cmd.assert().failure().stderr(predicate::str::contains(
"Error: Error opening \"LLVM.lock\" file",
));
Ok(())
}

0 comments on commit 21ae1cc

Please sign in to comment.