Merge pull request #444 from kdheepak/github-actions-ci-test

This commit is contained in:
Dheepak Krishnamurthy 2022-04-28 09:57:54 -06:00 committed by GitHub
commit 0265e4f826
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 27 deletions

View file

@ -31,13 +31,22 @@ jobs:
profile: minimal profile: minimal
toolchain: stable toolchain: stable
override: true override: true
- run: sudo apt-get update && sudo apt-get install -y taskwarrior - run: sudo apt-get update
- name: Compile taskwarrior
run: |
cd /tmp
git clone https://github.com/GothenburgBitFactory/taskwarrior
cd taskwarrior
git checkout v2.6.1
cmake -DCMAKE_BUILD_TYPE=release -DENABLE_SYNC=OFF .
make
sudo make install
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
repository: kdheepak/taskwarrior-testdata repository: kdheepak/taskwarrior-testdata
path: taskwarrior-testdata path: taskwarrior-testdata
- run: | - run: |
ulimit -a task --version
- run: | - run: |
# prepare taskwarrior, initial setup # prepare taskwarrior, initial setup
task rc.confirmation=off || echo 0 task rc.confirmation=off || echo 0

View file

@ -245,15 +245,13 @@ impl TaskwarriorTui {
.arg("rc.defaultwidth=0") .arg("rc.defaultwidth=0")
.arg("show") .arg("show")
.output() .output()
.context("Unable to run `task show`.") .context("Unable to run `task show`.")?;
.unwrap();
if !output.status.success() { if !output.status.success() {
let output = std::process::Command::new("task") let output = std::process::Command::new("task")
.arg("diagnostics") .arg("diagnostics")
.output() .output()
.context("Unable to run `task diagnostics`.") .context("Unable to run `task diagnostics`.")?;
.unwrap();
return Err(anyhow!( return Err(anyhow!(
"Unable to run `task show`.\n{}\n{}\nPlease check your configuration or open a issue on github.", "Unable to run `task show`.\n{}\n{}\nPlease check your configuration or open a issue on github.",
String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stdout),
@ -268,12 +266,12 @@ impl TaskwarriorTui {
let output = std::process::Command::new("task") let output = std::process::Command::new("task")
.arg("--version") .arg("--version")
.output() .output()
.context("Unable to run `task --version`") .context("Unable to run `task --version`")?;
.unwrap();
let task_version = Versioning::new(String::from_utf8_lossy(&output.stdout).trim()).unwrap(); let task_version =
Versioning::new(String::from_utf8_lossy(&output.stdout).trim()).context("Unable to get version string")?;
let (w, h) = crossterm::terminal::size()?; let (w, h) = crossterm::terminal::size().unwrap_or((50, 15));
let tick_rate = if c.uda_tick_rate > 0 { let tick_rate = if c.uda_tick_rate > 0 {
Some(std::time::Duration::from_millis(c.uda_tick_rate)) Some(std::time::Duration::from_millis(c.uda_tick_rate))
@ -3874,11 +3872,7 @@ mod tests {
} }
async fn _test_taskwarrior_tui() { async fn _test_taskwarrior_tui() {
let app = TaskwarriorTui::new("next", false).await; let app = TaskwarriorTui::new("next", false).await.unwrap();
if app.is_err() {
return;
}
let app = app.unwrap();
assert!(app.task_by_index(0).is_none(), "Expected task data to be empty but found {} tasks. Delete contents of {:?} and {:?} and run the tests again.", app.tasks.len(), Path::new(env!("TASKDATA")), Path::new(env!("TASKDATA")).parent().unwrap().join(".config")); assert!(app.task_by_index(0).is_none(), "Expected task data to be empty but found {} tasks. Delete contents of {:?} and {:?} and run the tests again.", app.tasks.len(), Path::new(env!("TASKDATA")), Path::new(env!("TASKDATA")).parent().unwrap().join(".config"));

View file

@ -56,13 +56,13 @@ impl EventLoop {
pub fn new(tick_rate: Option<std::time::Duration>, init: bool) -> Self { pub fn new(tick_rate: Option<std::time::Duration>, init: bool) -> Self {
let (tx, rx) = mpsc::unbounded_channel(); let (tx, rx) = mpsc::unbounded_channel();
let _tx = tx.clone(); let _tx = tx.clone();
let mut reader = crossterm::event::EventStream::new();
let should_tick = tick_rate.is_some(); let should_tick = tick_rate.is_some();
let tick_rate = tick_rate.unwrap_or(std::time::Duration::from_millis(250)); let tick_rate = tick_rate.unwrap_or(std::time::Duration::from_millis(250));
let (abort, mut abort_recv) = mpsc::unbounded_channel(); let (abort, mut abort_recv) = mpsc::unbounded_channel();
if init { if init {
let mut reader = crossterm::event::EventStream::new();
tokio::spawn(async move { tokio::spawn(async move {
loop { loop {
let delay = tokio::time::sleep(tick_rate); let delay = tokio::time::sleep(tick_rate);

View file

@ -540,14 +540,3 @@ where
StatefulWidget::render(self, area, buf, &mut state); StatefulWidget::render(self, area, buf, &mut state);
} }
} }
#[cfg(test)]
mod tests {
use super::*;
#[test]
#[should_panic]
fn table_invalid_percentages() {
Table::new([""].iter(), vec![Row::Data([""].iter())].into_iter()).widths(&[Constraint::Percentage(110)]);
}
}