Skip to content

Commit

Permalink
refactor: remove span based test filters (FuelLabs#4280)
Browse files Browse the repository at this point in the history
## Description
closes FuelLabs#3988.

We added these span based filters as it was possible to declare
duplicate dependencies in a transitive manner and this was causing tests
to be duplicated. After the recent re-work of our module structure, it
is not possible to declare such packages anymore, so we do not need
these filters in-place.


## Checklist

- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.

Co-authored-by: Joshua Batty <[email protected]>
  • Loading branch information
kayagokalp and JoshuaBatty authored Mar 14, 2023
1 parent 4e590ce commit 6794228
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions forc-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashSet, fs, path::PathBuf, sync::Arc};
use std::{fs, path::PathBuf, sync::Arc};

use forc_pkg as pkg;
use fuel_abi_types::error_codes::ErrorSignal;
Expand Down Expand Up @@ -172,16 +172,13 @@ impl<'a> PackageTests {

/// Run all tests for this package and collect their results.
pub(crate) fn run_tests(&self) -> anyhow::Result<TestedPackage> {
// TODO: Remove this once https://github.com/FuelLabs/sway/issues/3947 is solved.
let mut visited_tests = HashSet::new();
let pkg_with_tests = self.built_pkg_with_tests();
// TODO: We can easily parallelise this, but let's wait until testing is stable first.
let tests = pkg_with_tests
.bytecode
.entries
.iter()
.filter_map(|entry| entry.kind.test().map(|test| (entry, test)))
.filter(|(_, test_entry)| visited_tests.insert(&test_entry.span))
.map(|(entry, test_entry)| {
let offset = u32::try_from(entry.finalized.imm)
.expect("test instruction offset out of range");
Expand Down Expand Up @@ -323,9 +320,6 @@ impl TestResult {
impl BuiltTests {
/// The total number of tests.
pub fn test_count(&self) -> usize {
// TODO: Remove this once https://github.com/FuelLabs/sway/issues/3947 is solved.
let mut visited_tests = HashSet::new();

let pkgs: Vec<&PackageTests> = match self {
BuiltTests::Package(pkg) => vec![pkg],
BuiltTests::Workspace(workspace) => workspace.iter().collect(),
Expand All @@ -337,7 +331,6 @@ impl BuiltTests {
.entries
.iter()
.filter_map(|entry| entry.kind.test().map(|test| (entry, test)))
.filter(|(_, test_entry)| visited_tests.insert(&test_entry.span))
.count()
})
.sum()
Expand Down

0 comments on commit 6794228

Please sign in to comment.