• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

GothenburgBitFactory / taskwarrior / 10336191094

11 Aug 2024 02:06AM UTC coverage: 84.973% (+0.2%) from 84.733%
10336191094

push

github

web-flow
Use TaskChampion 0.7.0, now via cxx instead of hand-rolled FFI (#3588)

TC 0.7.0 introduces a new `TaskData` type that maps to Taskwarrior's
`Task` type more cleanly. It also introduces the idea of gathering lists
of operations and "committing" them to a replica.

A consequence of this change is that TaskChampion no longer
automatically maintains dependency information, so Taskwarrior must do
so, with its `TDB2::dependency_sync` method. This method does a very
similar thing to what TaskChampion had been doing, so this is a shift of
responsibility but not a major performance difference.

Cxx is .. not great. It is missing a lot of useful things that make a
general-purpose bridge impractical:

 - no support for trait objects
 - no support for `Option<T>` (https://github.com/dtolnay/cxx/issues/87)
 - no support for `Vec<Box<..>>`

As a result, some creativity is required in writing the bridge, for
example returning a `Vec<OptionTaskData>` from `all_task_data` to allow
individual `TaskData` values to be "taken" from the vector.

That said, Cxx is the current state-of-the-art, and does a good job of
ensuring memory safety, at the cost of some slightly awkward APIs.

Subsequent work can remove the "TDB2" layer and allow commands and other
parts of Taskwarrior to interface directly with the `Replica`.

255 of 279 new or added lines in 7 files covered. (91.4%)

7 existing lines in 4 files now uncovered.

19011 of 22373 relevant lines covered (84.97%)

23094.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

41.67
/src/main.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright 2006 - 2021, Tomas Babej, Paul Beckingham, Federico Hernandez.
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
//
12
// The above copyright notice and this permission notice shall be included
13
// in all copies or substantial portions of the Software.
14
//
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
//
23
// https://www.opensource.org/licenses/mit-license.php
24
//
25
////////////////////////////////////////////////////////////////////////////////
26

27
#include <cmake.h>
28
// cmake.h include header must come first
29

30
#include <Context.h>
31
#include <rust/cxx.h>
32

33
#include <cstring>
34
#include <iostream>
35
#include <new>
36
#include <regex>
37

38
////////////////////////////////////////////////////////////////////////////////
39
int main(int argc, const char** argv) {
4,497✔
40
  int status{0};
4,497✔
41

42
  Context globalContext;
4,497✔
43
  Context::setContext(&globalContext);
4,497✔
44

45
  // Lightweight version checking that doesn't require initialization or any I/O.
46
  if (argc == 2 && !strcmp(argv[1], "--version")) {
4,497✔
47
    std::cout << VERSION << "\n";
1✔
48
  } else {
49
    try {
50
      status = Context::getContext().initialize(argc, argv);
4,496✔
51
      if (status == 0) status = Context::getContext().run();
4,496✔
52
    }
53

54
    catch (const std::string& error) {
×
55
      std::cerr << error << "\n";
×
56
      status = -1;
×
57
    }
58

NEW
59
    catch (rust::Error& err) {
×
NEW
60
      std::cerr << err.what() << "\n";
×
NEW
61
      status = -1;
×
62
    }
63

64
    catch (std::bad_alloc& error) {
×
65
      std::cerr << "Error: Memory allocation failed: " << error.what() << "\n";
×
66
      status = -3;
×
67
    }
68

69
    catch (const std::regex_error& e) {
×
70
      std::cout << "regex_error caught: " << e.what() << '\n';
×
71
    }
72

73
    catch (...) {
×
74
      std::cerr << "Unknown error. Please report.\n";
×
75
      status = -2;
×
76
    }
77
  }
78

79
  return status;
4,497✔
80
}
4,497✔
81

82
////////////////////////////////////////////////////////////////////////////////
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc