Skip to content

Commit

Permalink
Merge branch 'master' into GH-678
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarshg6 committed Mar 24, 2023
2 parents 3a284ff + ec3677d commit 5376464
Show file tree
Hide file tree
Showing 56 changed files with 1,560 additions and 613 deletions.
4 changes: 2 additions & 2 deletions automap/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion automap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "automap"
version = "0.7.0"
version = "0.7.2"
authors = ["Dan Wiebe <dnwiebe@gmail.com>", "MASQ"]
license = "GPL-3.0-only"
copyright = "Copyright (c) 2019-2021, MASQ (https://masq.ai) and/or its affiliates. All rights reserved."
Expand Down
3 changes: 2 additions & 1 deletion ci/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ echo "*** AUTOMAP HEAD
cd "$CI_DIR/../automap"
ci/all.sh "$PARENT_DIR"
echo "*** AUTOMAP TAIL ***"
echo "*********************************************************************************************************"
echo "*********************************************************************************************************"

64 changes: 64 additions & 0 deletions ci/bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

if [ $# != 1 ]
then
echo "Please provide version as the first argument"
exit 1
fi

version="$1"
CI_DIR="$( cd "$( dirname "$0" )" && pwd )"
pushd "$CI_DIR/../"

echo "Searching for crates..."

crates=($(find . -type d -exec bash -c '[ -f "$0"/Cargo.toml ]' '{}' \; -print))

if [[ "${#crates[@]}" == "0" ]]; then
echo "No crates found."
exit 1
else
echo "Found ${#crates[@]} crate(s): ${crates[*]}"
fi

file=Cargo.toml
final_exit_code=0
declare -a grep_failures
declare -a lockfile_failures

bump_version() {
# Catches every `version` that begins a line and doesn't end with a comma.
find_pattern='^version\s*=.*[^,]\s*$'
replace_pattern='s/'$find_pattern'/version = "'"$version"'"/'

grep -q "$find_pattern" "$file" && sed -i "$replace_pattern" "$file"
exit_code="$?"
if [[ "$exit_code" != "0" ]]; then
final_exit_code=1
grep_failures+=($1)
return
fi

cargo generate-lockfile
exit_code="$?"
if [[ "$exit_code" != "0" ]]; then
final_exit_code=1
lockfile_failures+=($1)
fi
}

for crate in "${crates[@]}"
do
pushd "$crate"
bump_version "$crate"
popd
done

if [[ $final_exit_code != 0 ]]; then
[[ "${#grep_failures[@]}" != "0" ]] && echo "Failed to find 'version' for ${#grep_failures[@]} crate(s): ${grep_failures[*]}"
[[ "${#lockfile_failures[@]}" != "0" ]] && echo "Failed to generate lockfile for ${#lockfile_failures[@]} crate(s): ${lockfile_failures[*]}"
else
echo "The version number has been changed to $version."
fi

exit $final_exit_code
4 changes: 2 additions & 2 deletions dns_utility/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dns_utility/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dns_utility"
version = "0.7.1"
version = "0.7.2"
license = "GPL-3.0-only"
authors = ["Dan Wiebe <dnwiebe@gmail.com>", "MASQ"]
copyright = "Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved."
Expand Down
2 changes: 1 addition & 1 deletion masq/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "masq"
version = "0.7.1"
version = "0.7.2"
authors = ["Dan Wiebe <dnwiebe@gmail.com>", "MASQ"]
license = "GPL-3.0-only"
copyright = "Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved."
Expand Down
13 changes: 6 additions & 7 deletions masq/src/terminal/terminal_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::terminal::secondary_infrastructure::{
use linefeed::{Interface, Signal};
use masq_lib::command::StdStreams;
use masq_lib::constants::MASQ_PROMPT;
use masq_lib::utils::WrapResult;
use std::sync::Arc;

#[cfg(not(test))]
Expand Down Expand Up @@ -65,8 +64,9 @@ impl TerminalWrapper {
if std::env::var(prod_cfg::MASQ_TEST_INTEGRATION_KEY)
.eq(&Ok(prod_cfg::MASQ_TEST_INTEGRATION_VALUE.to_string()))
{
TerminalWrapper::new(Arc::new(prod_cfg::IntegrationTestTerminal::default()))
.wrap_to_ok()
Ok(TerminalWrapper::new(Arc::new(
prod_cfg::IntegrationTestTerminal::default(),
)))
} else {
//we have no positive test aimed at this (only negative and as an integration test)
Self::configure_interface_generic(Box::new(prod_cfg::DefaultTerminal::new))
Expand All @@ -80,11 +80,10 @@ impl TerminalWrapper {
F: FnOnce() -> std::io::Result<TerminalType>,
TerminalType: linefeed::Terminal + 'static,
{
Self::new(Arc::new(interface_configurator(
Ok(Self::new(Arc::new(interface_configurator(
terminal_creator_of_certain_type,
Box::new(Interface::with_term),
)?))
.wrap_to_ok()
)?)))
}
}

Expand All @@ -109,7 +108,7 @@ where

set_all_settable_parameters(interface.as_mut())?;

TerminalReal::new(interface).wrap_to_ok()
Ok(TerminalReal::new(interface))
}

fn set_all_settable_parameters<I>(interface: &mut I) -> Result<(), String>
Expand Down
3 changes: 1 addition & 2 deletions masq/src/test_utils/mocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use masq_lib::command::StdStreams;
use masq_lib::constants::DEFAULT_UI_PORT;
use masq_lib::test_utils::fake_stream_holder::{ByteArrayWriter, ByteArrayWriterInner};
use masq_lib::ui_gateway::MessageBody;
use masq_lib::utils::WrapResult;
use std::cell::RefCell;
use std::fmt::Arguments;
use std::io::{Read, Write};
Expand Down Expand Up @@ -624,7 +623,7 @@ impl InterfaceWrapper for InterfaceRawMock {
if let Err(err) = taken_result {
Err(err)
} else {
(taken_result.unwrap() as Box<dyn WriterLock + 'static>).wrap_to_ok()
Ok(taken_result.unwrap() as Box<dyn WriterLock + 'static>)
}
}

Expand Down
2 changes: 1 addition & 1 deletion masq_lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "masq_lib"
version = "0.7.1"
version = "0.7.2"
authors = ["Dan Wiebe <dnwiebe@gmail.com>", "MASQ"]
license = "GPL-3.0-only"
copyright = "Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved."
Expand Down
3 changes: 1 addition & 2 deletions masq_lib/src/multi_config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved.

use crate::shared_schema::{ConfiguratorError, ParamError};
use crate::utils::WrapResult;
#[allow(unused_imports)]
use clap::{value_t, values_t};
use clap::{App, ArgMatches};
Expand Down Expand Up @@ -78,7 +77,7 @@ impl<'a> MultiConfig<'a> {
_ => return Err(Self::make_configurator_error(e)),
},
};
MultiConfig { arg_matches }.wrap_to_ok()
Ok(MultiConfig { arg_matches })
}

pub fn make_configurator_error(e: clap::Error) -> ConfiguratorError {
Expand Down
19 changes: 0 additions & 19 deletions masq_lib/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,25 +314,6 @@ fn expect_value_panic(subject: &str, found: Option<&dyn fmt::Debug>) -> ! {
)
}

pub trait WrapResult {
fn wrap_to_ok<E>(self) -> Result<Self, E>
where
Self: Sized;
fn wrap_to_err<T>(self) -> Result<T, Self>
where
Self: Sized;
}

impl<T> WrapResult for T {
fn wrap_to_ok<E>(self) -> Result<Self, E> {
Ok(self)
}

fn wrap_to_err<V>(self) -> Result<V, Self> {
Err(self)
}
}

pub fn type_name_of<T>(_examined: T) -> &'static str {
std::any::type_name::<T>()
}
Expand Down
2 changes: 1 addition & 1 deletion multinode_integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "multinode_integration_tests"
version = "0.7.1"
version = "0.7.2"
authors = ["Dan Wiebe <dnwiebe@gmail.com>", "MASQ"]
license = "GPL-3.0-only"
copyright = "Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved."
Expand Down
2 changes: 1 addition & 1 deletion multinode_integration_tests/docker_dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

OUTPUT_DIR="$1"
mkdir -p "$OUTPUT_DIR"
for container in $(docker ps -a | tail -n +2 | cut -c 128- | grep test_node_)
for container in $(docker ps -a | tail -n +2 | cut -c 177- | grep test_node_)
do
./docker_logs.sh "$container" > "$OUTPUT_DIR"/"$container".log
done
Loading

0 comments on commit 5376464

Please sign in to comment.